Using Microsoft. visualstudio. testtools. unittesting;
If the DLL is
C: \ Program Files \ Microsoft Visual Studio 9.0 \ common7 \ ide \ publicassemblies \ Microsoft. visualstudio. qualitytools. unittestframework. dll
If the version is 9.0.0.0, [classinitialize] indicates that this method must be a static public method. If no value is returned and a testcontext parameter is used, an error is returned! I don't know if it is a Microsoft Bug.
Solution:
Change the DLL to c: \ Program Files \ Microsoft Visual Studio 11.0 \ common7 \ ide \ referenceassemblies \ V2.0 \ Microsoft. visualstudio. qualitytools. unittestframework. dll.
Version: 10.1.0.0
[Classinitialize]
Public static void myclassinitialize (testcontext context)
{
Sysconfig. loadcfg ();
}
Share a standard Ms Unit Test method:
# Region additional test features // You can also use the following features when writing a test: // use classinitialize to run the code before the first test in the running class [classinitialize ()] public static void myclassinitialize (testcontext) {} run the Code [classcleanup ()] public static void myclasscleanup () {} Use testinitialize to run the Code [testinitialize ()] public void mytestinitialize () {} before running each test. Use testcleanup to run the Code [testcleanup ()] After running each test. public void mytestcleanup () {}# endregion