unit testing

 Mockito really helps when you want to make white box testing. In addition to testing the results of some code, you can make sure that the code makes necessary method calls during its execution. 

For example, the following method prints the current time:

public MyClass {
  public void printTime(PrintStream ps) {
    ps.print("Current time is: ");
    Date now=new Date();
    SimpleDateFormat sdf=new SimpleDateFormat("hh:mm");
    ps.print(sdf.format(now));
  }
}

Let's try to test this code. We want to make sure the code calls PrintStream 2 times, ignore the first call and check that the second one is in correct format: two digits, colon(:) and another two digits.

I started with writing a custom ArgumentMatcher just to check there is a semicolon in a string:

andrew 14/06/2011 - 18:33

Thread Weaver is a test framework that gives a control over thread execution, which is important if you want to test race conditions and such. I haven't tried it, it it looks nice from the "outside" - here is their wiki. Will be glad to get a feedback from users.

Itsu Tamam 14/11/2009 - 04:27

There are more then one mock object frameworks for .NET.

Two of most popular are Rhino.Mocks and Moq. Both are mature and have reach API.

 

 

igorz 02/11/2009 - 10:42

Here are the slides from today's presentation.

 

Please do not hesitate to ask question or suggest your ideas in this thread.

 

 

andrew 23/07/2009 - 22:19

PNUnit is a powerful extension to NUnit which allows to create tests executing in parallel. This can drastically improve the quality of multi-threaded and distributed software, as usual tests will not reveal synchronization problems.

 

http://www.codicesoftware.com/opdownloads2/oppnunit.aspx

andrew 08/07/2009 - 11:47
Syndicate content