4

I had a simple C# program that had a set of Unit Tests. This was developed on Visual Studio 2010. Now on another computer I tried to reload this solution with Visual Studio 2012 and run the tests. I was able to rebuild the solution successfully however none of the unit tests show up in Test Explorer. The Visual Studio project (solution) was located on a LaCie Ethernet network drive. I copied the entire solution to my local C: drive, closed the solution from the network drive and reopened the copied one on local C: drive. Now when I build solution Test Explorer shows all tests. I went back and opened the copy on the network drive and again Test Explorer shows no tests. It says to build the solution to see a list of tests, but after successfully building the solution which includes the main project and the unit test project it still displays the same message. See image below: enter image description here

Why is it having project located on network drive causes Unit Testing to fail like this with no failure message at all?

JonN
  • 2,498
  • 5
  • 33
  • 49

4 Answers4

7

We finally got this to work on a network share using the following commands:

setx COMPLUS_LoadFromRemoteSources 1

caspol -m -ag 1.2 -url file://<path>* FullTrust

For example, if the path is \\computer\share\, then the second command will be:

caspol -m -ag 1.2 -url file://\\computer\share\* FullTrust

(note the asterisk at the end of the path)

Close VS first, run the commands, restart VS. This worked for me without having to clean/build my project.

Chin
  • 19,717
  • 37
  • 107
  • 164
Gary
  • 71
  • 1
  • 2
  • I am now getting System.Security.SecurityException: That assembly does not allow partially trusted callers. Result StackTrace: at FrnklTest.UnitTest1.TestMethod1() – greg May 14 '15 at 22:40
3

Rebuild all the projects of the application, including any projects that contain test classes and test methods. They will appear in Test Explorer.

OR

Trying changing the async void to async task.

Like

[TestMethod]
public async Task<Customers> GetCustomers()
{
    var result = await ...
}

Reference: Unit Test Explorer does not show up Async Unit Tests for metro apps

Community
  • 1
  • 1
Furqan Safdar
  • 16,260
  • 13
  • 59
  • 93
  • As I said in my question I have already rebuilt the entire solution which only has two projects(the console app and the unit test project) and each of these only has one C# source file. The build of each of these is successful. But when project/solution is located on network drive Test Explorer fails to show any tests. Where is this "async void" to "async task" located? In source, properties? – JonN Sep 29 '12 at 18:48
  • I looked at your link but I am not using any test methods that use async or await keywords. All my test methods are public void. – JonN Sep 29 '12 at 19:03
2

The solution is actually only the first half of Gary's:

setx COMPLUS_LoadFromRemoteSources 1

More reading: http://connect.microsoft.com/VisualStudio/feedback/details/502353/running-unit-tests-from-network-drive

Schoonology
  • 121
  • 6
0

With .Net 5 you need to add the test command to the project.json list of commands.

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://localhost:5000",
    "test": "xunit.runner.dnx"
  },
JabberwockyDecompiler
  • 3,318
  • 2
  • 42
  • 54