English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-07-01 08:13:41 · 1 answers · asked by susu 2 in Computers & Internet Programming & Design

I want to do NUnit test on compact framework because the tests need to be run on a WindowsCE device ( the application depends heavily on SQLCE, which can not be emulated on desktop ).

2006-07-01 22:11:44 · update #1

1 answers

Hi, for whitebox testing it is clear that it is dealing code. You get ugly testing raw code :) It will get ugly :> But it is nice that your thinking of doing it since many people don't do it. Good software practicing, is good for the world!

Clearly the best Whitebox tool out there is CSUINT. It is similar to the other test suites for other programming languages.

Take a look at http://www.csunit.org/ There are many tutorials on that site as well.

Good Luck

PS: This tool works like the popular JUNIT!

For the good real life example :)

using System;
using csUnit;
using MyProject;
// MyProject is where the class to be tested exists.

namespace example {
///


/// Summary description for FooTests.
///

[TestFixture]
public class FooTests() {
public FooTests() {
// nothing to do here
}
///
/// Test the set and get methods of the MyClass.Value property
///

[Test]
public void TestValueProperty() {
MyClass obj = new MyClass();
Assert.Equals(0, obj.Value);
obj.Value = 25;
Assert.Equals(25, obj.Value);
}
}
}

using System;

namespace MyProject {
///
/// This is the class to be tested..
///


public class MyClass() {
private int _ival = 0;
public void MyClass() {
_ival = 25;
}
public int Value
{
get
{
return(_ival);
}
set
{
_ival = value;
}
}
}
}

As you see I am creating an object and testing it if the value is correct:) As you see it is straight forward by using the Assertion Calls. I am testing if the object value is 0 and then 25 which are both true.

You do that for each function your testing like if we have getCarInfo, I make a stub to visuallize all the dependencies and then test that function like string car = getCarInfo(1); Assert.Equals("sedan", car); So if my function returns my expected result, then I am correct else there is a bug.

Good Luck on your testing! Takes a bit of time to do it :>

But say your project depends on libraries like SQLCE, then you would need to create a MOCK that replicates the functionality of SQLCE so you don't need to use that library. So if some classes depend on that library, you can instead Create a MOCK class and use the method stubs to ensure your testing correctness is valid.

http://msdn.microsoft.com/msdnmag/issues/04/10/NMock/

2006-07-01 16:03:43 · answer #1 · answered by ? 6 · 2 2

fedest.com, questions and answers