FitNesse configuration files

耗尽温柔 提交于 2020-01-13 10:29:28

问题


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?


回答1:


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.




回答2:


yes it is possible but an awful load of work. you need to define a test-project where you have your tests in it and a "wrapper"-project where you have the functionality of providing the tests with data and configuration settings.



来源:https://stackoverflow.com/questions/654259/fitnesse-configuration-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!