我在詹金斯得到了一个奇怪的信息

时间:2014-08-06 10:29:59

标签: jenkins nunit mstest specflow fluentautomation

我想用jenkins测试一个specflow项目。 我只能测试一个项目。我只是更改它显示No tests to execute消息的测试文件。即使两个项目具有相同的内容,只有项目名称不同。为什么这样?什么原因? 请帮帮我,谢谢!

消息是:

Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\test2
Path To MSTest.exe: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe
Delete old result file file:/C:/Program%20Files%20(x86)/Jenkins/workspace/test2/TestResult.trx
[test2] $ "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe" /resultsfile:TestResult.trx "/testcontainer:C:\Users\Documents\Visual Studio 2013\Projects\test\test\bin\Debug\test.dll"
Microsoft (R) Test Execution Command Line Tool Version 12.0.21005.1
Copyright (c) Microsoft Corporation. All rights reserved.

Loading C:\Users\Documents\Visual Studio 2013\Projects\test\test\bin\Debug\test.dll...
Starting execution...
No tests to execute.
Processing tests results in file(s) TestResult.trx
FATAL: No MSTest test report files were found.
FATAL: No MSTest TRX test report files were found. Configuration error?
Build step 'Publish MSTest test result report' marked build as failure
Finished: FAILURE

是的。我只是调试所有test.I尝试将specflowfeaturesteps.cs中的内容放入Unit.cs.And尝试用jenkins运行它。然后我发现它只测试单元测试中的一个函数。

消息:

  

通过test.UnitTest1.login 1/1 test(s)通过

specflowfeature.feature:

Given I login pages with default test user and password
Then the page should show 'http://' on the screen

specflowfeaturesteps.cs:

 [Given(@"I login pages with default test user and password")]
 public void login_success()
 {
     I.Open("http://");
     I.Enter("cherry").In("#loginName");
     I.Enter("****").In("#password");
     I.Click("input[value='Log In']");
 }

 [Then(@"the page should show '(.*)' on the screen")]
 public void check_URL(string p0)
 {
     I.Assert.Url((uri) => uri.GetLeftPart(UriPartial.Path) == p0);
 }

1 个答案:

答案 0 :(得分:0)

默认情况下,SpecFlow使用NUnit生成测试。你确定SpecFlow正在生成MSTest测试吗?

我会打开生成的单元测试文件(在FeatureFile.feature.cs之类的功能文件下)并检查其中的测试是否有NUnit或MSTest测试。

您还可以检查配置以查看配置是否包含以下内容:

<specFlow>      
  <unitTestProvider name="MSTest" />
</specFlow>

或者这个:

<specFlow>
  <unitTestProvider name="NUnit" />
</specFlow>

另一种可能性是在没有生成单元测试的情况下签入代码(尽管只有在Visual Studio之外修改了功能文件,或者你没有在vs内部使用specflow插件时才会这样)