Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit test project cannot find assembly under test (or dependencies)

When I try to run my Unit Test project, I get the following error:

Could not load file or assembly 'ASSEMBLY_NAME, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

The system cannot find the file specified.

The assembly under test is located in the same solution and every project target .NET 4.0 framework. It worked for a while, but today I got this error again. I can't figure out what is wrong, because the error message doesn't tell me enough. (like; WHICH file could not be found..)

I've tried to add a new Test project, but also that one worked for a while before it gave me this same error message.

Is there anybody who can point me in the right direction?

Edit: In the diagnostic build log, the following error appears:

C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\
Microsoft.TeamTest.targets(14,5): 
error : Could not load file or assembly 'ASSEMBLY_NAME, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
The system cannot find the file specified.

Done executing task "BuildShadowTask" -- FAILED. (TaskId:671)

Done building target "ResolveTestReferences" in 
      project "ASSEMBLY_NAME.Tests.vbproj" -- FAILED.: (TargetId:985)
like image 304
Rhapsody Avatar asked Nov 03 '11 10:11

Rhapsody


People also ask

How do I run unit test cases in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

How do I create a test project in Visual Studio?

Add a Google Test project in Visual Studio 2022In Solution Explorer, right-click on the solution node and choose Add > New Project. Set Language to C++ and type test in the search box. From the results list, choose Google Test Project. Give the test project a name and choose OK.

How do I test a solution in Visual Studio?

Select the test project in Solution Explorer. On the Project menu, select Add Reference. In Reference Manager, select the Solution node under Projects. Select the code project you want to test, and then select OK.


2 Answers

Check Build->Configuration Manager... menu. All projects should have the same platform and column Build checked.

Also you can take a look into output of the build (Output window), it usually states more clearly which file could not be found.

like image 188
Snowbear Avatar answered Sep 30 '22 04:09

Snowbear


After checking out some additional search results I came across this question here at SA Private Accessor for method is not found .

After I deleted the *.accessor file, my test project stopped complaining and compiled succesfully.

Everybody thanks for their help!

like image 20
Rhapsody Avatar answered Sep 30 '22 04:09

Rhapsody