简体   繁体   中英

Why are all my Visual Studio test results "Not executed"

When I run my unit tests in my project I am seeing a result "Not executed" for every one. I have restarted my computer so I doubt this is some kind of hung process issue.

Google has revealed nothing. Does anyone have any ideas?

What a PITA! The IDE doesn't show any errors. In order to determine the error you have to do this

  1. Open the Visual Studio command prompt
  2. Change to the directory where the binary output of your test project is.
  3. Type mstest /testcontainer:The.Name.Of.Your.Test.Assembly.dll

At the bottom of the output you will see the following text

Run has the following issue(s):

In my case it was the following:

Failed to queue test run 'Peter Morris@PETERMORRIS-PC 2009-02-09 10:00:37': Test Run deployment issue: The location of the file or directory 'C:\\SomePath\\SomeProject.Tests\\bin\\Debug\\Rhino.Mocks.dll' is not trusted.

Now if VS had told me this in the IDE I could have fixed it in minutes! All you have to do is open Windows Explorer and find that DLL. Right-click on it and go to Properties. Then click the "Unblock" button.

What a complete waste of my time!

Unit tests not executed

I've found that it is good advice to never have a constructor for a unit test class. If anything in a constructor ever throws, the test will just be reported as "not executed". Put test initialization in a TestInitialize method instead. Exceptions thrown there are reported by the IDE.

Blocked Binaries

Usually you have to unblock the ZIP file itself before you extract binaries from it, and then all the binaries will be unblocked. If you try to unblock the binaries themselves the unblocking doesn't "stick".

Another reason for "Failed to queue test run 'XXX'. The path is not of a legal form. " is that the account does not have a profile loaded.

Eg when you start mstest.exe with CreateProcessAsUser() and forget to call LoadUserProfile() as well.

If you try to start a test run from IIS the "Failed to queue test run 'XXX'. The path is not of a legal form." can be thrown if the user who runs the application pool does not have a user profile . In order to solve this just set Load User Profile to true in the application pool advanced settings.

see https://social.msdn.microsoft.com/Forums/vstudio/en-US/7bb32a2d-7d10-4b8e-b743-e5beb1175917/trigger-mstest-from-app-hosted-on-iis?forum=csharpgeneral

and https://blogs.msdn.microsoft.com/vijaysk/2009/03/08/iis-7-tip-3-you-can-now-load-the-user-profile-of-the-application-pool-identity/

for more info

确保您的测试类和测试方法是公开的。

In my case I had a circular reference in my code. Compile worked, but the tests just marked as "Not run".

Sometimes the error could also be " Failed to queue test run 'XXX'. The path is not of a legal form. "

The solution could be to change the TRX naming pattern in .testsettings file.

The quote from http://social.msdn.microsoft.com/Forums/da-DK/vststest/thread/c6efa2ba-1657-41bc-85b1-5a889d111e2f :

If you want control the name of this .trx file, open you Solution Explorer, open Local.testsettings in Solution Items, select General, change Default naming scheme to User-defined scheme. And then,

  1. You could run the test with VS to get the .trx file you defined.

  2. If you want get this result in command line, you could run it with /testsettings:Local.Testsettings. For more information, see http://msdn.microsoft.com/en-us/library/ms182489.aspx#testsettings .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM