Why are all my Visual Studio test results “Not executed”

前端 未结 7 1182
-上瘾入骨i
-上瘾入骨i 2020-12-29 05:07

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.

相关标签:
7条回答
  • 2020-12-29 05:29

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

    0 讨论(0)
  • 2020-12-29 05:32

    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

    0 讨论(0)
  • 2020-12-29 05:35

    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".

    0 讨论(0)
  • 2020-12-29 05:36

    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.

    0 讨论(0)
  • 2020-12-29 05:36

    Make sure your test class and test methods are public.

    0 讨论(0)
  • 2020-12-29 05:41

    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!

    0 讨论(0)
提交回复
热议问题