How remove test discover errors for SpecFlow tests? - mstest

I started to play with SpecFlow and the SpecFlow+ Runner. Now I want to stick with MsTest v2.
So I removed the SpecFlow runner packages and added SpecFlow.MsTest package to my project. It also contains MsTest.TestAdapter and MsTest.TestFramework.
Test Explorer in Visual Studio shows all tests, and I can also run all of them from there.
But on the Test output panel, I see some errors like:
Unable to fetch symbols for class: Name of my feature file
And also:
Unable to fetch source Information for test method: test method
Any ideas where these errors are coming from and how to remove them?

Related

TFS 2017 - how to run a build with code coverage?

Hi I'm trying to run a build with code coverage, I am using Visual Stuido 2017 enterprise I have tried to enable the code coverage in VS but if i click on Edit build definition in team explorer it opens the build definition in TFS.
Apologies for the delay in posting this as an answer.
As a prerequisite to using Code Coverage, the first thing to do is to install Visual Studio Enterprise on the build agent (Which you have already done). Following this, you must then update your builds to specify that Code Coverage is/should be enabled.
To enable code coverage, ensure you have included a Visual Studio Test task (or any equivalent which supports Coverage) in your build definition.
Once you have added the Test task, you'll want to configure this task and set your test assemblies, for this you can use an absolute path to point to a DLL file, or use wildcards like I do here
$(build.sourcesDirectory)\Source\Tests**\Release*Test*.dll
This says that in my sources directory I have a folder called Source, and inside that is a Tests folder which contains all of my unit tests. Then in each Unit Tests folder I use a wildcard to say "any folder at all that contains a Release folder", look inside and take the DLL which has 'Test' in its name.
So now that the testing assemblies are gathered, you can tick the checkbox that says "Code Coverage Enabled", and you're good to go.
I will edit this post later today to include screenshots of my own personal VSTS builds.

TFS 2013 Build Summary Not Showing Test Results

Similar issue as this question (which does not have an answer), except we are using TFS 2013 Update 4. Our tests are written using NUnit and are configured to run through the build definition, which uses the default (not upgrade) template.
We just installed a full version of VS 2013 Premium on the build server (because prior tests were not being run at all). With that installed, the tests are run (if I did down into the log I can see them and the results, and if we force a failure the build appropriately fails) but the build summary says that 0/0 tests were run.
I followed the steps in the selected answer to this question, and it now shows the code coverage results, but still no dice on the actual tests or their results.
I also found this blog article that appears to be the same issue from TFS 2010. I have verified that all users have the View Test Runs permission set to allow, and I tried using a TFS administrator account just to be sure. Still no dice.
How do I make TFS show me what tests were run in the summary, and also in the Test Results window that the build summary links to?
Each individual test needs to be associated with a test case work item in Team Foundation Server. See this link for information on how to associate your tests. In my work, we're using TFS 2015, but I know this works in TFS 2013 as I have done this work in the past. Once the test case work item is associated with your automation (using Visual Studio to link the test automation to the test case) then there must be a build definition for the product under test that runs your test automation as part of the build. When a build is queued, your tests are run as part of the new build. Once the build is done, you can then view the detailed test results.
Plus the other StackOverflow post here describes how to view the detailed results.

SpecFlow not listing NUnit with VS2013

I had tried all the way on the web.
But it still not listing NUnit in Tools -> Options -> SpecFlow test runner.
I install "NUnit Test Adapte" already.
I tried to attach NUnit but I can't find "NUnit" in available process.
Is I having wrong way to install NUnit? I downloaded the NUnit.zip and decompressed it in Program files.Did it need more steps to install it?And I also install the NUnit package in VS2013.
What's wrong did I done?Or what isn't done yet?
Please help me.
As the comment said, there are too many things that could be wrong. Here are a few suggestions you could try.
Verify feature files are being converted into tests.
How to Verify: In VS solution explorer, expand the feature file and you should see a feature.cs file.
Solution to fix: install the SpecFlow solution
Verify the test is a nunit test and not mstest
How to Verify: Open the feature.cs file and verify you see NUnit somewhere on that page and your scenario (no spaces) should have [TestAttribute] above it.
Solution to fix: Add nunit reference to the project & in the project's app.config Add NUnit as the provider
Verify NUnit Test Adapter is installed
How to Verify: Write a simple nunit test & see if it shows up in the test explorer window.
Solution to fix: Install it or you can always install SpecRun as an alternative. VS Test explorer should show your tests and they can be run from there.
Verify all your tests are mapped
How to Verify: Your tests should be black except where you have variables. Hitting F12 should go to definition.
Solution to fix: There can be a caching issue but for the most part, verify the regex is correct and make sure the step definition is visible to the feature file. That means it's either in the same project or is included in the app.config as a known step assembly.

Using XUnit with Visual Studio Online

I've setup my build as below using the build definition. I'm using XUnit and locally my tests are discovered and run. I've tested the glob **\*spec*.dll and it finds all my test dlls and the build log shows that those dlls are in fact built.
However in the build log I get
Run VS Test Runner
No test found. Make sure that installed test
discoverers & executors, platform & framework
version settings are appropriate and try again.
Which seems to suggest it is trying to use the MSTest test runner instead of the XUnit test runner. How do I tell the build for visual studio online to use the XUnit test runner and discoverer?
This might be out of date now, but this is how I have it setup and working - downvote and let me know if it's wrong and I'll delete this. I got it from a blog post/MSDN page, but I can't locate it any more.
First you need to create a TFVC Team Project (doesn't matter if you don't use it again).
Into $/MyTFVC/BuildProcessTemplate/CustomActivities/
Checking the following files from xunit.net:
Now in VS, click the BUILD, Manage Build Controllers... option. Select the "Hosted Build Controller (Hosted)" and click "Properties...".
Enter the path where you checked in the DLL's into the "Version control path to custom assemblies" field:
You should be good to go.

Visual Studio 2010 Test View doesn't find 2nd NUnit test project

I can see both test projects from the NUnit Gui (loaded separately) but I can not see both projects from the Visual Studio Test View. The Test View only shows the first/original project. Hitting reload doesn't do anything. How do I get the Test View to display the second/later project? It should show both at the same time/same view, yes?
If I can only see one project's test in the Test View by design, how do I get the Test View to change projects?
Details:
I created the second project by hand ie not "create a test" as a project library with the nunit.framework.dll referenced. I checked the assembly files of the two projects as well as the properties and they look the same.
I'm on VS 2010 Professional using NUnit 2.6.0.12051 with "Visual NUnit 2010" version 1.2.4 extension installed.
I have one NUnit test project that is working both in VS Test View and NUnit Gui. I added a second project with a [TestFixture] class and a [Test] method. All projects build sucessfully. Both tests refer to the nunit.framework.dll in a parent directory to both.
There is a tag in the project file describing a project as a test project.
In the PropertyGroup section of the csprj file, add this:
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
See more details here:
http://www.kindblad.com/2010/08/07/how-to-change-an-existing-visual-studio-project-into-a-test-project
There are many problems that can cause this. Here's what mine was:
I had 2 NUnit test projects.
"Test Explorer" -> "Run All" would only find tests from one project.
Explicitly right clicking on one of the tests that wasn't found and clicking "Run Test" resulted in "No tests found." in the Output window.
All projects on all configurations were set to Any CPU, but it didn't matter if X86 was chosen for everything either.
The problem was that my Visual Studio (2015, FWIW) was using Test Adapter 2.x, and one of my projects had pulled NUnit 3.0 using NuGet. Test Adapter 2.x doesn't run NUnit 3 tests, so my NUnit 3 test project was being ignored.
To solve the problem:
Uninstall all NUnit Test Adapters (from Visual Studio -> Tools -> Extensions and Updates and from each project's NuGet Package Manager window).
Update all test projects to NUnit 3.0 using each project's NuGet Package Manager Window.
Install the NUnit3 Test Adapter from Visual Studio -> Tools -> Extensions and Updates
Notes:
If you need to stick to NUnit 2, then just install the appropriate Test Adapter. The important thing is consistency.
If you were using test adapters installed by NuGet before, but switched to a Visual Studio Extension, then you may have problems loading resources/files from path strings. See this answer to solve that issue.

Resources