Gennadiy Donchyts Just another WordPress weblog

20Dec/090

Fitnesse4net source code is available on Google Code

I've uploaded source code for .NET version of FitNesse4Net to Google Code. It is simply original version of FitNesse but converted to .NET using IKVM.NET and then extended with a small wrapper allowing to use default test runner to run .NET tests. Also command-line is a bit extended so that it can run as a server or command-line runner. See source code and binaries here: FitNesse4Net on Google Code

Filed under: FitNesse, Test No Comments
10Dec/090

Just learned from ReSharper how to make code look nicer

ReSharper really helps to learn how to code. During writing a test for a ForEach extension method for IEnumerable<T> it suggested to improve the following code:

ReSharper_group1

The resulting code got much better:

ReSharper_group2

7Dec/090

Update version of FitNesse for .NET.

This time a command-line and MSBuild runners are included: fitnesse4net-bin.zip 8.3Mb

After experimenting a bit more with FitNesse I managed to make it run .NET assemblies with about 15Kb of source code injected directly into FitNesse internals :) . It not tested much so probably some bugs will need to be fixed, but it is able to run demo .NET assemblies without any problems. The main purpose was proof of concept, to see if it will work at all and try to develop a MSBuild tasks allowing to run all tests using command-line.

What is included:

fitnesse4net

DemoTest1 page contains the following text:

!contents
!|script|DemoProject.MultiplierBy2|
 |input|2|
 |run|
 |check|output|4|
 !|script| DemoProject.MultiplierBy2|
 |input|2|
 |run|
 |check|output|5|

The file content.txt in FitNesseRoot/ is used to find a list of assemblies to be referenced, looks like this:

!path ..\DemoProject\bin\Debug\DemoProject.dll

After run of run-test-suite.cmd the following output should be printed and the target/ directory should contain results of the tests as html.

Loading assembly ..\DemoProject\bin\Debug\DemoProject.dll ...
Running test suite FrontPage.DemoSuite ...
Running test FrontPage.DemoSuite.DemoTest1 ...
Test results: 3 right, 1 wrong, 0 ignored, 0 exceptions
Running test FrontPage.DemoSuite.DemoTest2 ...
Test results: 4 right, 0 wrong, 0 ignored, 0 exceptions
fitnesse4net-results

Contents of FitNesse.proj:

<Project>
<UsingTask TaskName="Tasks.RunSlimTestSuite" AssemblyFile="..\bin\FitNesse4Net.MSBuidTasks.dll" />
<UsingTask TaskName="Tasks.RunSlimTest" AssemblyFile="..\bin\FitNesse4Net.MSBuidTasks.dll" />

<Target Name="RunSlimTestSuite">
   <RunSlimTestSuite WorkingDirectory=".\src\DemoProject.Tests" TargetDirectory=".\target" TestSuiteName="FrontPage.DemoSuite" />
</Target>

<Target Name="RunSlimTest">
   <RunSlimTest WorkingDirectory=".\src\DemoProject.Tests" TargetDirectory=".\target" TestName="FrontPage.DemoSuite.DemoTest1" />
   <RunSlimTest WorkingDirectory=".\src\DemoProject.Tests" TargetDirectory=".\target" TestName="FrontPage.DemoSuite.DemoTest2" />
</Target>

</Project>

msbuild-run-test-suite.cmd:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe FitNesse.proj /t:RunSlimTest

msbuild-run-test.cmd:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe FitNesse.proj /t:RunSlimTestSuite

run-test-suite.cmd:

..\bin\FitNesse4Net.exe --run-test-suite=FrontPage.DemoSuite --work-directory=.\src\DemoProject.Tests --target-directory=.\target

run-test.cmd:

..\bin\FitNesse4Net.exe --run-test=FrontPage.DemoSuite.DemoTest1 --work-directory=.\src\DemoProject.Tests --target-directory=.\target

start-server.cmd:

start ..\bin\FitNesse4Net.exe --port=8080 --work-directory=.\src\DemoProject.Tests

stop-server.cmd:

..\bin\FitNesse4Net.exe --shutdown --port=8080

After FitNesse4Net.exe is started without arguments, usage help will be printed to the console. Many options are similar to those provided by Java fitnesse.jar but some are new like --shutdown, --run-test-suite, --run-test

Note: after run of start-server.cmd - it will generate a lot of other files in your FitNesseRoot.

fitnesse4net-bin/
|
|   README
|
+---bin
|       fitnesse.dll .......................... original java fitnesse.jar
|       FitNesse4Net.exe ...................... main .NET executable
|       FitNesse4Net.MSBuidTasks.dll
|       IKVM.OpenJDK.Core.dll
|       IKVM.OpenJDK.Misc.dll
|       IKVM.OpenJDK.Security.dll
|       IKVM.OpenJDK.Text.dll
|       IKVM.OpenJDK.Util.dll
|       IKVM.OpenJDK.XML.dll
|       IKVM.Runtime.dll
|       log4net.dll
|       NDesk.Options.dll
|
\---examples
|   FitNesse.proj
|   msbuild-run-test-suite.cmd .............. example scripts showing how to run FitNesse
|   msbuild-run-test.cmd                      using command-line runner or MSBuild
|   run-test-suite.cmd
|   run-test.cmd
|   start-server.cmd
|   stop-server.cmd
|
\---src
+---DemoProject
|   |   DemoProject.csproj
|   |   MultiplierBy2.cs
|   |
|   +---bin
|   |   \---Debug
|   |           DemoProject.dll .......... system under test
|   |           DemoProject.pdb
|   |
|   \---Properties
|           AssemblyInfo.cs
|
\---DemoProject.Tests
|
|
\---FitNesseRoot
|   content.txt
|   properties.xml
|
+---files ......................... some files required to generate reports
|
\---FrontPage
|   content.txt
|   properties.xml
|
\---DemoSuite ................. demo test suite
|   content.txt
|   properties.xml
|
+---DemoTest1
|       content.txt
|       properties.xml
|
\---DemoTest2
content.txt
properties.xml
DemoTest1 contains the following text:
!contents
!|script|DemoProject.MultiplierBy2|
|input|2|
|run|
|check|output|4|
!|script| DemoProject.MultiplierBy2|
|input|2|
|run|
|check|output|5|
content.txt in FitNesseRoot is used to find a list of assemblies to be referenced. Usually it looks like:
!path ..\DemoProject\bin\Debug\DemoProject.dll
After run of run-test-suite.cmd the target/ directory will contain results of the tests as html.
...
Note1: after run of start-server.cmd - it will generate a lot of other files in your FitNesseRoot.
FitNesse.proj:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Tasks.RunSlimTestSuite" AssemblyFile="..\bin\FitNesse4Net.MSBuidTasks.dll" />
<UsingTask TaskName="Tasks.RunSlimTest" AssemblyFile="..\bin\FitNesse4Net.MSBuidTasks.dll" />
<Target Name="RunSlimTestSuite">
<RunSlimTestSuite WorkingDirectory=".\src\DemoProject.Tests" TargetDirectory=".\target" TestSuiteName="FrontPage.DemoSuite" />
</Target>
<Target Name="RunSlimTest">
<RunSlimTest WorkingDirectory=".\src\DemoProject.Tests" TargetDirectory=".\target" TestName="FrontPage.DemoSuite.DemoTest1" />
<RunSlimTest WorkingDirectory=".\src\DemoProject.Tests" TargetDirectory=".\target" TestName="FrontPage.DemoSuite.DemoTest2" />
</Target>
</Project>
msbuild-run-test-suite.cmd:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe FitNesse.proj /t:RunSlimTest
msbuild-run-test.cmd:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe FitNesse.proj /t:RunSlimTestSuite
run-test-suite.cmd:
..\bin\FitNesse4Net.exe --run-test-suite=FrontPage.DemoSuite --work-directory=.\src\DemoProject.Tests --target-directory=.\target
run-test.cmd:
..\bin\FitNesse4Net.exe --run-test=FrontPage.DemoSuite.DemoTest1 --work-directory=.\src\DemoProject.Tests --target-directory=.\target
start-server.cmd:
start ..\bin\FitNesse4Net.exe --port=8080 --work-directory=.\src\DemoProject.Tests
stop-server.cmd:
..\bin\FitNesse4Net.exe --shutdown --port=8080

After FitNesse4Net.exe is stared, a list of possible options will be printed to the console. Many options a similar to those provided by Java fitnesse.jar but some are new like --shutdown, --run-test-suite, --run-test

TODO: check if it will work as a test runner from FitNesse wiki (currently it will say that runner is not found if you try to run tests from the fitnesse wiki).

Filed under: Test No Comments
6Dec/090

Got stack overflow on StackOverflow :)

StackOverflow

Filed under: Uncategorized No Comments
1Dec/091

Using FitNesse under .NET without JRE

Not sure if anyone will use it but it was kind of funny thing to do. After playing with FitNesse (Function Integration Testing Framework) which is mainly developed in Java I check if it can be converted to .NET using IKVM and the trick seems to work, you can start server, edit pages and runs tests. It is simply packaged version of fitnesse.jar and .NET runner by by Mike Stockdale. ... uses pure Java version.

Download: fitnesse4net.zip 8.7Mb

Zip file contains only .NET binaries required to run FitNesse and small demo project containing a single class. No Java is required.

After starting run_server.cmd you have to wait until FitNesse will unpack all it's files into FitNesseRoot, then press refresh in browser. After you run demo test on a root page you should get something like this (the web page has been updated, see another blog post for a new version):

fitnesse-results

It works a bit slower compare to Java but still seems to be stable.

Directory structure:

fit4net-directory

fit4net
|
+---bin
|       fit.dll
|       fitnesse.exe ................ FitNesse all in one wiki/server
|       fitSharp.dll
|       IKVM.OpenJDK.Core.dll
|       IKVM.OpenJDK.Misc.dll
|       IKVM.OpenJDK.Security.dll
|       IKVM.OpenJDK.Text.dll
|       IKVM.OpenJDK.Util.dll
|       IKVM.OpenJDK.XML.dll
|       IKVM.Runtime.dll
|       Runner.exe .................. command-line test runner, fetches content from server
|       RunnerW.exe ................. same as previous, but with window
|
\---example
|   run_server.cmd
|
+---FitNesseRoot
|       content.txt
|       properties.xml
|
\---src
|   DemoFitNesseTests.csproj
|   DemoFitNesseTests.sln
|   DemoMultiplierBy2.cs
|
\---bin
\---Debug
DemoFitNesseTests.dll

Right now I'm struggling trying to integrate it with MSBuild / TeamCity, looks like nobody implemented it yet :( DONE

Filed under: Uncategorized 1 Comment