I've got a C# .NET class library MyClassLibrary that compiles fine. I'm trying to create a unit test project for it (using Visual Studio Unit Testing Framework, with Visual Studio 2010). The class library does have big classes in it, but whenever I run even the simplest test against the simplest class, I get the following exception:
Test method MyClassLibraryTest.MyClassLibraryTests.MySimpleClassTest threw exception: System.TypeLoadException: Could not load type 'MyClassLibrary.MySimpleClass' from assembly 'MyClassLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
All of the projects I'm dealing with are in the same solution, and all are compiled for .NET 4.0. All of this is on a Windows 7 64-bit machine.
Here's the weird part: when I "Run" the test, I get the above error. But when I "Debug" the test, it runs fine. Why?
You need to close the Test Explorer Window to prevent automatic running.
Automated testing frameworks today. Today we will compare three automated testing tools namely Selenium, QTP (Quality Test Professional) and Coded UI Test (CUIT) with Visual Studio 2012.
To run all the tests in a default group, choose the Run icon and then choose the group on the menu. Select the individual tests that you want to run, open the right-click menu for a selected test and then choose Run Selected Tests (or press Ctrl + R, T).
To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.
I just banged my head against this one for an hour. The problem was that I had a command line project named Something.exe, which was using a class library project named Something.dll.
Happened to me too. In my case the problem arised because the tested project and the unit tests project had the same name. If this is your case too then rename one of the projects and rename output file name to fix it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With