2

I want to test a specflow project with jenkins. And I can test only one project.I just change test file that it show No tests to execute message.Even two project has the same contents, only project name are different.Why such like this? What's the reason? Please help me,thank you!

The message is:

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

yes.I just debug all test.I try to put contents in specflowfeaturesteps.cs into Unit.cs.And try to run it with jenkins.Then I find it just test only one function in Unit test.

the message:

Passed test.UnitTest1.login 1/1 test(s) Passed

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);
 }
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
cherry
  • 21
  • 5

1 Answers1

0

By default SpecFlow generates its tests using NUnit. Are you sure that SpecFlow is generating MSTest tests?

I would open the generated unit test file (under the feature file something like FeatureFile.feature.cs) and check if the tests in there are NUnit or MSTest tests.

you can also check in the config to see if the configuration contains this:

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

or this:

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

The other possibility is that the code is checked in without the unit tests being generated (although this is only likely if the feature files are modified outside of visual studio, or you are not using the specflow plugin inside vs)

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
  • Thank you for your answer. But it seems jenkins test the UnitTest.cs file.How can I make it test specflowfeature files? – cherry Aug 07 '14 at 02:03
  • @cherry, you cannot test specflow feature files, that is not the way specflow works. Specflow **generates unit test files from the feature file** and then **ANY** test runner can run those unit tests. Did you check the specflow configuration? When you open the solution in visual studio you can see the unit tests generated by opening the `MyFeature.feature.cs` file which is a child of the MyFeatur.feature file in the solution explorer tree. Does the MSTest unit test runner run the tests in VS? are the `MyFeature.feature.cs` files checked in? – Sam Holder Aug 07 '14 at 06:39
  • Plus, please don't Mark the answer as accepted if it doesn't solve your problem. This will just confuse users with the same problems in the future. – Sam Holder Aug 07 '14 at 07:31
  • thank you for your remind.But I don't understand what you want to say clearly.I use jenkins to run MSTest.And specflowfeature.feature, NUnit.cs and specflowfeaturesteps.cs are in project. I write code in specflowfeaturesteps.cs. – cherry Aug 07 '14 at 08:10
  • ok, first, can you run the specflow tests in Visual Studio? If so **how** are you running them? Second, please update the question with the contents of these files: specflowfeature.feature and specflowfeature.feature.cs – Sam Holder Aug 07 '14 at 08:30