简体   繁体   English

如何将参数传递给Fitnesse .NET命令行任务运行器

[英]How to pass arguments to the Fitnesse .NET command line task runner

I have a Fitnesse.NET acceptance test suite that I want to run as part of my TFS/MSBuild CI build. 我有一个Fitnesse.NET验收测试套件,我希望它作为我的TFS / MSBuild CI版本的一部分运行。

The suite contains some Fitnesse variables that I need to override when calling from the build process, eg: 该套件包含一些Fitnesse变量,我需要在构建过程中调用时重写这些变量,例如:

!define ConnectionString {Data Source=...}

How can I override the variable values defined in the suite when calling the suite from the command line test runner? 从命令行测试运行程序调用套件时,如何覆盖套件中定义的变量值?

I'd like to be able to do something like: 我希望能够做到这样的事情:

Tests\TestRunner.exe -v -results test.results localhost 8082 MyTestSuite -P:ConnectionString={MyBuildServerDB}

Any ideas? 有任何想法吗?

The symbolic link trick of the first answer works nicely. 第一个答案的符号链接技巧很好用。

Another solution is to use environment variables or java variables. 另一种解决方案是使用环境变量或java变量。 Any environment or java variable can be accessed from a fitnesse page as though it was a variable. 可以从fitnesse页面访问任何环境或java变量,就好像它是一个变量一样。 So if you have ${MYVAR} on a fitnesse page, and you have a MYVAR environment or java variable, then it will use the value of the environment or java variable. 因此,如果您在fitnesse页面上有$ {MYVAR},并且您有MYVAR环境或java变量,那么它将使用环境或java变量的值。

Im not sure of a way to pass one into the runner, but you could make symbolic pages that define your variables differently and then you just call the different page. 我不确定将一个传递给跑步者的方法,但是您可以制作以不同方式定义变量的符号页面,然后您只需调用不同的页面。 For example in our setup we can run our tests with in-memory repositories or with MySQl as the database. 例如,在我们的设置中,我们可以使用内存存储库或使用MySQl作为数据库来运行测试。 This allows us to run the entire suite very fast and then CI can run the slow ones. 这使我们可以非常快速地运行整个套件,然后CI可以运行缓慢的套件。

So we have two pages that contain a symbolic link. 所以我们有两个包含符号链接的页面。 The properties looks like this: 属性如下所示:

<?xml version="1.0"?>
<properties>
    <Help></Help>
    <LastModified>20090427102431</LastModified>
    <Search/>
    <Suite/>
    <Suites></Suites>
    <SymbolicLinks>
        <MustPass>.FrontPage.MustPass</MustPass>
    </SymbolicLinks>
    <saveId>1231186112073</saveId>
    <ticketId>3122308994585074329</ticketId>
</properties>

and the contents looks like this: 内容如下:

!define repository_type {InMemory}

This is the test suite for in-memory tests. Run this instead of running the !-MustPass-! suite.

!contents -R2 -g -p -f -h

Then the runner can get the pages to run as a param something like this: 然后跑步者可以将页面作为这样的参数运行:

.\dotnet\TestRunner -format xml -results results.xml localhost 8080 FrontPage.MemoryMustPass

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

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