Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FitNesse configuration files

Tags:

I'm using FitNesse as a functional testing framework. I'm running into trouble when FitNesse runs code that needs configuration.

If I need to get a connection string from the configuration file, I can get it to work by adding it to the FitServer.exe.config. However, I don't like that solution. I would like FitNesse to load my own configuration file, namely TheNameOfMyApp.dll.config.

Is this possible?

like image 940
grootjans Avatar asked Mar 17 '09 13:03

grootjans


1 Answers

Sure, easy to do. I'm assuming you're using the dotnet or dotnet2 test runner. I'm using the dotnet2 test runner, and here's how I've got it set up:

First, when you !define your COMMAND_PATTERN, include -c suite.config. For instance, I have the following in root:

!define COMMAND_PATTERN {%m -c suite.config %p}
!define TEST_RUNNER {..\..\bin\Debug\FitServer.exe}

suite.config goes in the same dir as fitnesse.jar:

<suiteConfig>
    <fit.Settings>
        <appConfigFile>..\..\MyProjectFolder\fitnesse\MyProjectName.config</appConfigFile>
    </fit.Settings>
    <fit.Assemblies>
    </fit.Assemblies>
    <fit.FileExclusions>
        <add>^\.svn$</add>
    </fit.FileExclusions>
    <fit.Namespaces>
    </fit.Namespaces>
    <fit.CellHandlers>
    </fit.CellHandlers>
    <fitlibrary.CellHandlers>
    </fitlibrary.CellHandlers>
</suiteConfig>

MyProjectName.config looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="keyname" value="something" />
    </appSettings>

</configuration>

You can make things easier for yourself if you use an absolute path for the appConfigFile. I started off with an absolute path, got things working, then switched to a relative path by trial and error.

Note that I'm running my test runner from a non-standard location, which will affect the relative path in suite.config. The path is relative to your TEST_RUNNER location, NOT to suite.config or fitnesse.jar.

like image 173
Joseph Anderson Avatar answered Oct 12 '22 03:10

Joseph Anderson