DOTNET development – automatic builds and tests

1. General remarks

Most of the successfull open source projects are using some elementary tools which have influence to the way the developer is working. If several team members have a common goal

common_goal

it is important that the project resources are managed in a save and easy way. Usually all relevant files should be checked in to a revision control system like Mercurial, Git, Subversion, CVS etc. This implies that everything that is needed to build the project is also under revision control.

To be able to handle merge conflicts easily, tools like Winmerge are a great help. BUT tools like Winmerge are only effective if the files they are comparing are text files with a structure that show differences line by line when comparing different versions.

Build tools like NANT have xml like files to control all the build processes, why NANT fits very good in this concept.

To allow new developers to start developing without fear to produce some hidden errors in the project, unit tests (thank you Kent Beck) give the necessary security. If after a change all tests still pass everything should be fine. This implies on the other hand that all code parts are tested in some test cases.

Log4Net Logging framework is well suited to add logging command to the code with the possibility to configure the output with respect to log levels per class.

Let’s put all the parts together ….

2. Requirements / Preconditions

Most important: Get a cup of coffee first! cup_of_coffee

  • DOTNET Framework
  • NAnt
  • Nunit
  • NUnit2Report
  • MySQL DOTNET Connector
  • Log4Net

3. The complete working example

As a start point for your own project you may download a complete example project with a simple unit test case which tests a simple count of a mysql database table.

nunit_example

To compile, build and test the project with test report generation afterwards use the command from the commandline in the project directory:

The generated unit test report is realized using frames and allows flexibel browsing in the test results.

testreport

Other NAnt targets defined in the example project are build, test, run.

4. Links / References

[1] Microsoft DOTNET Framework http://goo.gl/IRqzJg
[2] NAnt http://goo.gl/OLoihi
[3] Log4net http://goo.gl/PjtYU9
[3] NUnit http://goo.gl/mLzNmD
[5] NDoc http://goo.gl/RUc5Pq
[3] NUnit2Report http://goo.gl/QIEtSn

Leave a Reply

Your email address will not be published. Required fields are marked *

This blog is kept spam free by WP-SpamFree.