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

Iam new for white box testing.I have put in white box testing of c#.net applications.I am not understanding how the application is to be tested.which of them to be test.which should be not.How to write test cases for the functions.I want one good example of real life application Class.cs and the test cases of that Class.cs with clear explanation.Iam using the NUnit to test by dll's.

2006-06-20 16:57:09 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 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 :>

2006-06-20 17:11:21 · answer #1 · answered by ? 6 · 0 0

White Box Test Cases Example

2016-12-10 19:54:32 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers