.net - TypeInitializationException when running mstest from command line -
We have a subset of unit test that was always running through Visual Studio recently. I am now working on a continuous integration setup which will run the test. When all the tests pass through the visual studio, but when I try to run them from the command line using mstest they fail with "TypeInitializationException" which says that the dll file for this type is not Can get it.
System Typing Initialization: foo.bar_Accessor 'for the startizer threw an exception --- & gt; System.IO.FileNotFoundException: The file or assembly could not load the file 'foo, version = 1.0.0.0, culture = neutral, public keypoint = null' or one of its dependencies could not specify the system file. Encashment Manager is loaded with: c: \ WINDOWS \ Microsoft.NET \ framework \ v2.0.50727 \ mscorwks.dll
DLL is a project reference in question in the unit test project There is also a test reference which creates the foo.bar_Accesor version of the class.
I have noticed that when the test is run through the visual studio, the "coverage _timestamp" folder is created in which IN and one out in the folder OUT folder, among other things, foo.dll and foo_accesor .dll
When tests are run from the command line, a "user name _timestamp" folder is created in which there is only one out folder. In addition to other things in the OUT folder, foo_accesor.dll is not, but foo.dll which is outlined in the error message.
I have solved it with the / nyzolation
switch for us this switch Has been described as:
Run the test within the MSTest.exe process. This option improves the speed of the test run but increases the risk of the MSTest.exe process.
My MSBuild script now looks something like this:
& lt; Target name = "test" DependsOnTargets = "compilation" & gt; & Lt; PropertyGroup & gt; & Lt; TestSuccessOrNot & gt; 1 & lt; / TestSuccessOrNot & gt; & Lt; / PropertyGroup & gt; & Lt; Exec Command = '$ (VS100COMNTOOLS) .. \ IDE \ mstest.exe "/ noisolation /testcontainer:"C:\path\to\test.dll"'> Output Task parameter = "ExitCode" property Name = "TestSuccessOrNot" /> & lt; error condition = "$ (TestSuccessOrNot) == 1" text = "unit test failed!" / & Gt; & lt; / target & Gt;
Comments
Post a Comment