Working with NUnit tests: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
== Instructions ==
== Instructions ==
* Download the latest version from http://www.nunit.org/
* Download the latest version from https://launchpad.net/nunitv2/
* run <code>nant generateSolution</code> once; then running <code>nant compile</code> will compile the tests for OpenPetra (and re-running it will recompile the tests)
* run <code>nant generateSolution</code> once; then running <code>nant compile</code> will compile the tests for OpenPetra (and re-running it will recompile the tests)
* You will find the resulting tests in dlls in the directory <code>delivery/bin/</code>.
* You will find the resulting tests in dlls in the directory <code>delivery/bin/</code>.

Revision as of 14:53, 24 July 2012

Instructions

  • Download the latest version from https://launchpad.net/nunitv2/
  • run nant generateSolution once; then running nant compile will compile the tests for OpenPetra (and re-running it will recompile the tests)
  • You will find the resulting tests in dlls in the directory delivery/bin/.
  • Open the dll that you want to test, eg. Tests.Common.dll, with NUnit. You can now run a single test, or run all tests at once.
    • Note: run the 32 bit version of nunit if you are on Win 7 (found in %ProgramFiles(x86)% and usually has "x86" in the executable name).


  • Looking at the code, you will see annotations for the methods, eg. [SetUp], [Test] etc. This is for setting up the testing environment, clean it up, defining which method is a test, etc. See the NUnit documentation or the existing test cases for more details.

Ict.Common tests

  • We have quite simple function tests, eg. in csharp\ICT\Testing\Common
  • We have tests for string operations (TStringHelper), Database operations, CSV&XML Input/Output, etc.

Printing test

  • This test in csharp\ICT\Testing\Common\Printing does not use the NUnit framework, but allows the user to see how an HTML file gets printed to paper or PDF.

Client forms test

NUnitForms

We make use of NUnitForms (http://nunitforms.sourceforge.net/). The project is alive, even though the last release is a couple of years old. We have our compiled dll of the latest VCS snapshot in our own VCS, in csharp\ThirdParty\NUnit.

We have made small modifications to NUnitForms so that it works for our generated forms with all the random Layout control names blurring the path to controls. The modifications are maintained in csharp\ThirdParty\NUnit\src.

Integration tests

Basically, these tests are integration tests, since our DLL Ict.Testing.NUnitClient.dll (project in csharp\ICT\Testing\NUnitPetraClient) is a full OpenPetra client, allows a demo user to login to the separately running server, and then open OpenPetra screens as if it was a normal user. There is currently no mock-up server.

Existing tests with samples

  • We have a project in csharp\ICT\Testing\MFinance\GLForm which does create GL Batches, post them, and does some checks.

Server function tests

We have a full server wrapped up in a dll, in csharp\ICT\Testing\NUnitPetraServer, Ict.Testing.NUnitServer.dll. This server allows a user to login, and then access the webconnector functions, Database access, and basically everything else inside the server.

Existing samples

  • see project csharp\ICT\Testing\MFinance\server\Gift, which has a simple test for DataAccess and for a WebConnector.