简体   繁体   English

FitNesse或FitSharp是否支持通用配置文件?

[英]Does FitNesse or FitSharp support a general-purpose configuration file?

I know there is a plugins.properties file for configuring the FitNesse environment and customizing it, and that FitSharp supports a suite configuration file for certain environment settings. 我知道有一个plugins.properties文件,用于配置FitNesse环境并对其进行自定义,并且FitSharp支持某些环境设置的套件配置文件。 But does FitNesse or FitSharp support a general purpose configuration file, for setting symbols or markup variables? 但是FitNesse或FitSharp是否支持用于设置符号或标记变量的通用配置文件?

The reason I ask is that I'm using RestFixture, a plug-in that allows calls to RESTful web services. 我问的原因是我正在使用RestFixture,这是一个允许调用RESTful Web服务的插件。 A RestFixture table takes the host URL as a fixture argument. RestFixture表将主机URL作为fixture参数。 I'd like to move the host URL out of the test pages into a configuration file, so that the test pages are identical in different environments, such as dev, test and production. 我想将主机URL从测试页面移到配置文件中,以便在不同的环境(例如开发,测试和生产)中测试页面完全相同。

Defining a markup variable in the root page gets me most of the way there but I'd prefer to move the variable out of any pages entirely. 在根页面中定义标记变量可以帮助我解决大部分问题,但是我希望将变量完全移出所有页面。

By the way, I'm using the .NET port of RestFixture, RestFixture.Net, so I'm really looking for a solution that applies to .NET / FitSharp. 顺便说一句,我正在使用RestFixture的.NET端口,RestFixture.Net,所以我真的在寻找适用于.NET / FitSharp的解决方案。

Running the same tests on different environments is archieved by using symbolic links. 通过使用符号链接可以在不同的环境中运行相同的测试。

As you are aware, you can set a variable for all the tests in a suit by putting it on the suite page: 如您所知,您可以通过将其放在套件页面上来为西装中的所有测试设置变量:

---
Suite
Help: Suite to contain tests for local testing
---
!define targetenvironment {http://localhost:8080}

Build this suite like this, so without any nested pages. 像这样构建此套件,因此没有任何嵌套页面。 Also build another suite page with the same property in it but with a different value. 还构建另一个具有相同属性但值不同的套件页面。

---
Suite
Help: Suite to contain tests for local testing
---
!define targetenvironment {http://192.168.10.1:8080}

Now build your testcases in a third suite and use this property as, per your example, the target. 现在,在第三个套件中构建您的测试用例,并根据您的示例将此属性用作目标。

Finally, go back to your first suite page and go to the page properties, where you can fill a Symbolic link, you basically instantiate the test suites. 最后,返回您的第一个套件页面并转到页面属性,您可以在其中填充符号链接,基本上可以实例化测试套件。 Now when running this suite page, the target property is filled in the tests. 现在,在运行此套件页面时,将在测试中填充目标属性。 When doing the same for the second suite page, you will find that in the tests, the target property is filled using that value. 当对第二个套件页面执行相同操作时,您会发现在测试中,使用该值填充了目标属性。

The Suite .wiki file would now look like this: Suite .wiki文件现在看起来像这样:

---
Suite
Help: Suite to contain tests for local testing
SymbolicLinks
  TestSet: .SuiteContainingTests
---
!define targetenvironment {http://localhost:8080}

And the suite containing tests can be seen in the browser. 在浏览器中可以看到包含测试的套件。

However, the tests are the same and no matter where you edit them (from suite 1, 2 or 3), you will always edit the same files. 但是,测试是相同的,并且无论您在何处进行编辑(从套件1、2或3),您都将始终编辑相同的文件。

It turns out the plugins.properties file is a general-purpose configuration file. 事实证明,plugins.properties文件通用配置文件。

I had read the FitNesse User Guide page about the plugin.properties file: http://www.fitnesse.org/FitNesse.UserGuide.AdministeringFitNesse.ConfigurationFile I took it to mean that the plugin.properties file only supported the specified built-in properties. 我已经阅读了关于Plugin.properties文件的《 FitNesse用户指南》页面: http : //www.fitnesse.org/FitNesse.UserGuide.AdministeringFitNesse.ConfigurationFile我认为它是指plugin.properties文件仅支持指定的内置文件。属性。 However, there was a little note at the bottom which I missed: 但是,我在底部错过了一个小字条:

Other properties 其他特性

There are more properties which can be used to tweak parts of FitNesse: 还有更多可用于调整FitNesse零件的属性:

... ...

  • Any variable that can be defined on a wiki page. 可以在Wiki页面上定义的任何变量。

I experimented and found that any key-value pair in the file, of the form key=value , can be read in a test page. 我进行了实验,发现文件中的任何键值对(形式为key=value )都可以在测试页中读取。

Some notes about usage: 有关用法的一些注意事项:

1) It appears that lines in the plugins.properties file starting with # (hash), // (two forward slashes), ; 1)似乎plugins.properties文件中的行以 (哈希), // (两个正斜杠)、;开头 (semi-colon) or :: (two colons) are all treated as comments. (分号)或 :(两个冒号)都被视为注释。 Or, more likely, they aren't comments per se but just don't cause any errors; 或者,更有可能的是,它们本身并不是评论,只是不会引起任何错误;

2) Backslashes in the plugins.properties file need to be escaped by doubling them. 2)plugins.properties文件中的反斜杠需要通过加倍来转义。 eg "C:\\FitNesse" should be written as C:\\\\FitNesse ; 例如“ C:\\ FitNesse”应该写为C:\\\\FitNesse ;

3) To reference a property from the plugins.properties file in a FitNesse test page use the FitNesse markup variable syntax: ${property name} 3)要使用FitNesse测试页中的plugins.properties文件引用属性,请使用FitNesse标记变量语法: $ {property name}
eg ${Theme} 例如$ {Theme}

4) Environment variables can be included in the plugins.properties file, using the FitNesse markup variable syntax. 4)使用FitNesse标记变量语法,可以将环境变量包含在plugins.properties文件中。 eg FitNessePluginsDirectory=${FITNESSE_HOME}\\\\Plugins , where FITNESSE_HOME is an environment variable. 例如FitNessePluginsDirectory=${FITNESSE_HOME}\\\\Plugins ,其中FITNESSE_HOME是环境变量。

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

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