FitNesse 配置文件

发布于 2024-07-15 09:00:05 字数 217 浏览 4 评论 0原文

我使用 FitNesse 作为功能测试框架。 当 FitNesse 运行需要配置的代码时,我遇到了麻烦。

如果我需要从配置文件中获取连接字符串,我可以通过将其添加到 FitServer.exe.config 来使其工作。 但是,我不喜欢这个解决方案。 我希望 FitNesse 加载我自己的配置文件,即 TheNameOfMyApp.dll.config。

这可能吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

诠释孤独 2024-07-22 09:00:05

当然,很容易做到。 我假设您正在使用 dotnet 或 dotnet2 测试运行程序。 我正在使用 dotnet2 测试运行程序,设置方法如下:

首先,当您定义 COMMAND_PATTERN 时,包括 -c suite.config。 例如,我在根目录中有以下内容:

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

suite.config 与fitnesse.jar 位于同一目录中:

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

MyProjectName.config 如下所示:

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

</configuration>

如果您对 appConfigFile 使用绝对路径,则可以使事情变得更容易。 我从绝对路径开始,让一切正常工作,然后通过反复试验切换到相对路径。

请注意,我从非标准位置运行测试运行程序,这将影响 suite.config 中的相对路径。 该路径是相对于您的 TEST_RUNNER 位置,而不是 suite.config 或fitnesse.jar。

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
lt;/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.

东北女汉子 2024-07-22 09:00:05

是的,这是可能的,但工作量很大。 您需要定义一个测试项目,其中包含测试,以及一个“包装器”项目,其中您具有为测试提供数据和配置设置的功能。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文