简体   繁体   English

FitNesse 配置文件

[英]FitNesse configuration files

I'm using FitNesse as a functional testing framework.我使用 FitNesse 作为功能测试框架。 I'm running into trouble when FitNesse runs code that needs configuration.当 FitNesse 运行需要配置的代码时,我遇到了麻烦。

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.如果我需要从配置文件中获取连接字符串,我可以通过将其添加到 FitServer.exe.config 来使其工作。 However, I don't like that solution.但是,我不喜欢这种解决方案。 I would like FitNesse to load my own configuration file, namely TheNameOfMyApp.dll.config.我希望 FitNesse 加载我自己的配置文件,即 TheNameOfMyApp.dll.config。

Is this possible?这可能吗?

Sure, easy to do.当然,很容易做到。 I'm assuming you're using the dotnet or dotnet2 test runner.我假设您使用的是 dotnet 或 dotnet2 测试运行器。 I'm using the dotnet2 test runner, and here's how I've got it set up:我正在使用 dotnet2 测试运行程序,这是我设置它的方式:

First, when you,define your COMMAND_PATTERN.首先,当你定义你的 COMMAND_PATTERN。 include -c suite.config, For instance: I have the following in root:包括 -c suite.config,例如:我在 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: suite.config 与 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: MyProjectName.config 如下所示:

<?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.如果您为 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.请注意,我正在从非标准位置运行我的测试运行程序,这将影响 suite.config 中的相对路径。 The path is relative to your TEST_RUNNER location, NOT to suite.config or fitnesse.jar.该路径与您的 TEST_RUNNER 位置相关,而不是与 suite.config 或 Fitnesse.jar 相关。

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.您需要定义一个包含测试的测试项目和一个“包装”项目,您可以在其中定义为测试提供数据和配置设置的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM