The problem is manifested in the following forms:
Unit Test Adapter threw exception: type is not resolved for member...
However, the same test is appliedProgram/No problems on the website
The root cause of this problem is:
Visual Studio running testCodeIs actually running in an independent appdomain, The appdomain cannot find the type stored in callcontext
Therefore, this exception is thrown, but the exception information is very unclear. It is difficult to find the cause of the exception only by looking at the exception information.
So far, there are three solutions:
1.taobao dllto qaagent32.exe directory (generally in the Visual Studio installation directory, usually c: \ Program Files \ Microsoft Visual Studio 10.0 \ common7 \ IDE)
This solution has no special requirements on DLL, which means it is troublesome.
You can add an automatic Copy command in post-build event command line in build event to simplify manual operations.
At the same time, qaagent32.exe will remain running, causing the file to be locked and cannot be automatically overwritten, therefore, you must set tools> Options> test tools> test excetion> to cancel the keep test exection engine running between test runs check.
2.modify assemblyredirect in qaagent32.exe. config to re-bind a path
3. register the Assembly to GAC (highly recommended)
The benefit of registering an assembly to GAC is not only that the Assembly can be run locally. When TFs build is used to run an automated test, the test can also be run on other machines without the need to configure it again.
In addition, there are many other advantages to make the Assembly a strong name (You can Google it yourself ~~~)
The generated assembly can be automatically registered to GAC after the build is successful.
The configuration steps are as follows:
1. gacutil.exe to the project file (there are many compatible versions of gacutil.exe with earlier versions)
2.right-click gacutil.exe-> properties-> copy to output directory and set it to copy If newer (and keep the build action as the default content)
3. Right-click Project properties-> build event-> post-build event command line to add the following code:
"$ (Targetdir) gacutil"-U "$ (targetname )"
"$ (Targetdir) gacutil"-I "$ (targetpath )"
@ Echo add assembly to GAC $ (targetpath)
The above code is to first remove the DLL with the same name from GAC, then register it, And then print some information.
PS: Okay .. In fact, there is another way to add an attribute.
[Deploymentitem ("arch. Base. Logging. API. dll")]
To specific methods