gpt4 book ai didi

configuration - FitNesse 配置文件

转载 作者:行者123 更新时间:2023-12-04 07:30:01 25 4
gpt4 key购买 nike

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

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

这可能吗?

最佳答案

当然,很容易做到。我假设您使用的是 dotnet 或 dotnet2 测试运行程序。我正在使用 dotnet2 测试运行器,这是我如何设置它的:

首先,当你定义你的 COMMAND_PATTERN 时,包括 -c suite.config。例如,我在 root 中有以下内容:

!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$</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。

关于configuration - FitNesse 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/654259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com