When i add test scenario in feature file it is not getting displayed after build. in VS 2015.
I had the same issue . And when I upgraded my specflow to 3.0.213 , feature.cs and tests were not generated. Then I used this MSBUild example with latest specflow to generate feature.cs and tests in test explorer. It uses MSTest as test runner.
Related
I have added a release definition in Visual Studio Team Services to deploy an application to a Azure cloud service. I'm trying to run some integration tests after a successful deployment:
But unfortunately tests are not run:
Warning: No test is available in C:\a\301532a74\Build\Api.Web.IntegrationTests\Api.Web.IntegrationTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
##[warning]No results found to publish.
I have installed the NUnit Test Adapter (nuget package) for all projects containing tests (unit tests and integration tests). The weird thing is that I am able to run the tests as part of a build but not as part of a release.
I also tried to set the Path to Custom Test Adapters but it doesn't seem to make a difference.
What I am missing here? Is there a better way to run some integration tests as part of a release?
This is usually caused by the NUnit test adapter cannot be found by VSTest.
Usually, In "Build" environment, NUnit test adapter is restored in working folder by nuget, so VSTest can find it during the testing. But in "Release" environment, NUnit test adapter does not exist by default. So you need to update your build definition to upload the NUnit test adapter files to "drop" and the NUnit test adapter will be avaiable in "Release" environment after the artifacts is downloaded. Then you can set the "Path to Custom Test Adapters" to "$(System.DefaultWorkingDirectory)\" and try again.
If you are using your own build agent, you can also place the NUnit Test Adapter in a permanent path that the build agent can access and set the "Path to Custom Test Adapters" to it. Or install NUnit test adapter extension for VS on the build agent and enter "/UseVsixExtensions:true" in "Visual Studio Test\Other console options".
I have found a solution for my problem, based on Eddie's suggestions:
Step 1 - Copy all NUnit assemblies to the output folder of the test project (set the Copy Local property to True)
Step 2 - Create an artifact that will contain all files of the bin folder of the test project. This will contain not only the test assemblies but also the NUnit assemblies
Step 3 - In the test task, set the Path to Custom Test Adapters to the artifacts folder that contains the test assemblies and the NUnit adapters assemblies
That's it! Next time you create a release and deploy to any environment tests will be executed.
My problem was that i didn´t have a testrunner for NUnit installed at all, since I´m using resharpers testrunner.
Therefore my solution was as simple as adding the nuget package, "NUnit3TestAdapter" version="3.4.0", to my test project.
In visualstudio.com (VS online) "Nuget restored adapters are automatically searched for." and you need not/should not specify a path for "Custom Test Adapters"
- I don´t know if this also works for NUnit test adapter version 2.
Recently we had a change to our Xunit and we upgraded to Xunit 2.0 and all projects to .NET 4.5. Before this change,when I ran the feature file, I remember seeing the steps on the output window (of Resharper unit test session) of a failed test and it would pinpoint where the test failed at. But now, it only shows what kind of error it is and no steps in the output pane.
Can anyone tell me how to get the steps back as it is very annoying and difficult to find out where the test failed.
Note: We are using specflow to write the tests and run them using Resharper. The version of Resharper I am using is 8.2.1000
Support for XUnit 2.0 does not exist in Specflow yet. There is an outstanding pull request, but it still has some issues I think. So I think your options are to revert to the previous version of XUnit or roll up your sleeves and contrbute to the open PR.
ENVIRONMENT
We are currently using 2 Chutzpah packages (this and this) in Visual Studio 2013 Update 4 to enable us to execute individual Jasmine unit tests (with Chutzpah context menu "Open in Browser") against an angular application we are developing.
We currently have to use Chrome developer tools to set breakpoints and debug the unit tests.
The current Jenkins build is running Moq Unit Tests against the C# application code and cross-browser Selenium tests with SauceLabs.
The next step for the JS tests is to execute them as part of our Jenkins build along with the other tests.
To achieve this the best tool currently is Intern.
OUR REQUIREMENTS
Execute JS Tests and calculate coverage as part of the Jenkins Build
on SauceLabs.
Execute and step through (debug) JS Unit Tests
Regarding 1, I can see from the Intern example that we will probably have to (and can) rewrite our tests for Intern to get them to execute on Jenkins and SauceLabs.
Regarding 2, the point of this post:
MY QUESTIONS
Can tests written in the manner of the Intern example be debugged in chrome with developer tools?
Is there a need for a Chutzpah-like tool to integrate Visual Studio
with Intern? (Is this the analogous tool?)
I am trying to implement xunit for test cases in my project and using VS 2012 Professional account.
The test case generation is done fine, but while running them, VS is unable to find any test case.
Tried running the test cases from VS inbuilt test option and using resharper's test option.
Please let me know, if some change in my approach is needed.
I have just added a specflow feature however the generated code is for NUnit. I would prefer to use Resharper to run the tests.
I installed specflow from NuGet. I did not install any runner projects.
Here is a sample of the generated .feature.cs
//
------------------------------------------------------------------------------ // <auto-generated> // This code was generated by SpecFlow (http://www.specflow.org/). // SpecFlow Version:1.9.0.77 // SpecFlow Generator Version:1.9.0.0 // Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //
------------------------------------------------------------------------------
#region Designer generated code
#pragma warning disable namespace Test.FeatureHanding {
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Set Filter")
By default, all SpecFlow tests are in NUnit! SpecFlow simply generates the tests from the plain text for you.
You simply have to click on the icon to the left of the test method declaration in the generated YourFeature.feature.cs file, or you Resharpers test explorer to find it.
I think there is a terminology misunderstanding here.
NUnit is a testing framework (others are xUnit, mbUnit, MSTest). NUnit comes with a test runner which can run unit tests written with the NUnit framework.
Resharper has a test runner which can run tests from many testing frameworks (all of the above frameworks I believe). There are other test runners available. Visual studio (2012+ I believe) come with a test runner which can run MSTest tests without a plugin. NCrunch can run tests from any of the frameworks, and xUnit and mbUnit probably have runners provided which can run tests written in those frameworks.
Once you have built your feature files then Resharper should find the tests that SpecFlow has generated.