How to get VS2010 to recognize my mstests created by SpecFlow?

I configured Specflow to configure the MsTest framework (instead of NUnit), specifying it the same way as in the app.config of my "specs" class library:

<configSections> <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/> </configSections> <specFlow> <unitTestProvider name="MsTest.2010" /> </specFlow> 

So, as soon as it appeared on the spot, I see that my test devices are created correctly using the special tool Specflow with the correct TestClassAttribute () and methods, etc.:

 [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.3.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute()] ... 

A specification class is being created, but now I cannot run tests using Test β†’ Run β†’ All Tests in Solution inside Visual Studio 2010 in my Vista 64 window. Why doesn't VS recognize them as valid tests to run?

+7
visual-studio-2010 bdd specflow
source share
3 answers

I had to recreate the project as a Test Project , and not just a Class Library - because I started development using NUnit and SpecFlow, I created a vanilla class library to store my specifications, which were decorated with NUnit attributes, I thought I could just change the app .config of this existing project to point to the mstest framework and stop using NUnit, but VS2010 never recognized the tests, despite the proper creation of stubs on the special specflow tool.

So ... I added a new Test Project to my solution, moved all my specification code to this new project, then recompiled and alt, VS2010 recognizes the tests. I am sure that there is a GUID that he is looking for in the XML of the .csproj file or something that tells him to connect the testing environment, but I haven’t gone that far.

Hope this helps someone.

+4
source share

According to Dror Helper and Alex Duggleby, you need to add the following line. Csproj file:

 <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> 

Add it after the FileAlignment element and reload the project. Now it should be an MS Test project, and you will get the MS Test functionality in the context of this project. Guides mean:

  • {3AC096D0-A1C2-E12C-1390-A8335801FDAB} - test project
  • {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - C # Class Library.
+8
source share

To modify the class library project template in a test project, modify .csproj and add the following line:

 <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> 

for the first element of the property group:

 <PropertyGroup> <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> 
-one
source share

All Articles