FitNesse is a wiki with tables that you can run to test your system . The tables then tell FitNesse about the creation of some classes, perform some operations on them, and check the result.
To work with .NET , for example, you just need to tell FitNesse how to communicate with .NET and which .NET assemblies to load. Nothing more .. A .NET project can be a simple class library without knowing FitNesse at all.
Tools required
- FitNesse - Java-based FitNesse showcase and test framework.
- fitSharp - contains .NET libraries for writing FIT and SliM.
Step Examples
Download FitNesse and fitSharp (in this example, fitSharp was extracted before D:\fit\fitSharp\release.1.9.net.35\ )
Run FitNesse from the command line:
java -jar fitnesse.jar -p 8080
Create and compile a C # Class Library project with
namespace ClassLibrary1 { public class ShouldIBuyMilk { private int _cash; private int _pintsOfMilkRemaining; private string _useCreditCard; public void SetCashInWallet(int cash) { _cash = cash; } public void SetCreditCard(string useCreditCard) { _useCreditCard = useCreditCard; } public void SetPintsOfMilkRemaining(int pints) { _pintsOfMilkRemaining = pints; } public string GoToStore() { if (_cash > 0 || _useCreditCard.Equals("yes")) return "yes"; return "no"; } } }
Go to http: // localhost: 8080 / , then click "[add child]" next to the heading and add the "Test" page.
Enter the contents of the wiki page as shown below (update the paths):
!define TEST_SYSTEM {slim} !define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,D:\fit\fitSharp\release.1.9.net.35\fitsharp.dll %p} !define TEST_RUNNER {D:\fit\fitSharp\release.1.9.net.35\Runner.exe} !path D:\fit\MyFixture\ClassLibrary1\bin\Debug\ClassLibrary1.dll !|import| |ClassLibrary1| |Should I buy milk| |cash in wallet|credit card|pints of milk remaining|go to store?| | 0 | no | 0 | no | | 10 | no | 0 | yes | | 0 | yes | 0 | yes | | 10 | yes | 0 | yes | | 0 | no | 1 | no |
Pay attention to '!' before !|import| Avoid ClassLibrary1, which should be considered a wiki word.
Save it and click "Test" in the menu on the left. FitNesse will load the assembly, instantiate your class, set some properties by matching the naming rules, and finally check some properties.
see also
Wernight
source share