Visual Studio 2010 is not recognized Unit Test

In an existing solution, I added a new test project. In my Project Project.cs file, I have a class decorated with the [TestClass] attribute and a method decorated with the [TestMethod] attribute. I checked that Configuration Manager has the build flag set for the test project (since my Google search was found, there was a problem for others with this problem). I set up a test project as my initial project for the solution. When I try to run a test, I get "I can not start a test project because the project does not contain any tests." I am really new to unit testing. What am I missing?

[TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { Whole bunch of stuff Assert.Inconclusive("Done"); } } 

Update. So, I opened a new instance of VS, went to File => New => Project => Test Project. Do not touch or edit anything. I went directly to the cs file, and here is its entire contents:

 using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestProject2 { public class Inspection { public bool SubmitInsp() { return true; } } [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { Inspection insp = new Inspection(); bool result = insp.SubmitInsp(); Assert.IsTrue(result); } } } 

Same error about a project that does not contain any test when I try to run it. Also found this in the output of the assembly "Could not load file or assembly" ~ \ my documents \ visual studio 2010 \ Projects \ TestProject2 \ bin \ Debug \ TestProject2.dll or one of its dependencies. The operation is not supported. (Exception from HRESULT: 0x80131515) "

I do not know that unit tests become much simpler. What the hell???

+6
source share
6 answers

In test projects saved in a network folder or anywhere locally on my computer, this problem occurs. I created another test project and saved it on my flash drive, it works fine. I don’t know if this is because my machine is 64-bit or because its virtual machine or something, but I think I just need to check everything on external storage devices.

+1
source

I managed to get this to work by modifying the devenv.exe configuration file found here:

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config .

Add the following line to the <runtime> section, then restart Visual Studio:

 <loadFromRemoteSources enabled = "true" /> 

(Here is the link that helped me)

+5
source

I had the same problem when tests in a working test project were suddenly not recognized.

Comparing the project file with one of the other working test projects showed me that the <ProjectTypeGuids> node was missing from the main <PropertyGroup> node.

Adding this line inside the <PropertyGroup> node solved my problem:

FROM#:

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

VB:

 <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids> 
+5
source

ansser FrstCBC did not work for me. I am on a VirtualBox machine with 64-bit versions of Windows 7 and Visual Studio 2012.

I had to move the output to a local folder : open the unit tests project properties, and on the Build tab, view the Output path . > to the local folder. Tests are now detected and can be run.

+2
source

It was simple for me that my class and method were not public (I understand that the poster has public , but I found this post using Googling "testclate testmethod margin icons missing"). A stupid mistake on my part, but maybe this will help others.

+1
source

Make sure that all .cs files are marked as Compilation in the Properties window. If it is marked as "Content", you will fall into this problem.

0
source

Source: https://habr.com/ru/post/924096/


All Articles