FitNesse配置文件 [英] FitNesse configuration files
问题描述
我使用FitNesse作为一个功能测试框架。我会遇到麻烦,当FitNesse运行需要配置的代码。
I'm using FitNesse as a functional testing framework. I'm running into trouble when FitNesse runs code that needs configuration.
如果我需要从配置文件中获取连接字符串,我可以通过添加它到FitServer.exe.config。但是,我不喜欢这个解决方案。我想FitNesse加载我自己的配置文件,即TheNameOfMyApp.dll.config。
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.
这是可能吗?
推荐答案
当然,很容易做。我假设你使用dotnet或dotnet2测试运行器。我使用的dotnet2测试跑者,这是我如何设置它:
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:
首先,当你定义你的COMMAND_PATTERN,包括-c suite.config 。例如,我在根目录中有以下:
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与fitnesse.jar在同一个目录中:
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看起来像这样:
MyProjectName.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="keyname" value="something" />
</appSettings>
</configuration>
如果您使用appConfigFile的绝对路径,我开始了一个绝对的路径,得到的东西工作,然后通过尝试和错误切换到相对路径。
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.
注意,我运行我的测试跑步从非 - 标准位置,这将影响suite.config中的相对路径。路径是相对于您的TEST_RUNNER位置,而不是到suite.config或fitnesse.jar。
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.
这篇关于FitNesse配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!