How does mstest.exe process a test DLL configuration file?

I am a little confused about how mstest.exe process app.config dll file.

Pilot project 1:

  • Trivial non-test DLL. (It does nothing but read and print the value of the application parameter from its own app.config file.)

  • The main EXE file that the DLL calls to print its configuration value.

Pilot project 2:

  • A unit test DLL, which contains only one test method for reading the value of an application parameter from its own app.config file and writing it to a file.

  • I am using mstest.exe to call the unit test DLL.

Result:

For 1. The DLL configuration value is not printed.

For 2. the native value of the DLL configuration is successfully read and written to the file.

So, is there something special in mstest.exe ?

Thanks.


I am using SOS.dll for debugging through my unit test DLL. I found that a separate application domain is created for each unit test DLL. And these application domains are different from the name named vstesthost.exe . I believe that the configuration is specific to the application domain . Mstest.exe will create an application domain for each of the test DLLs and upload its own configuration file to the application domain, respectfully.

Hope someone can give a more confident explanation.


How to load a configuration file in AppDomain? - load the configuration file into AppDomain, use this:

AppDomainSetup ad2setup = new AppDomainSetup ();

ad2setup.ConfigurationFile = @ "config file path";

+4
source share
1 answer

Yes, there is something special in mstest.exe. It will copy all the dlls links to another directory and execute from there (I'm not sure why it does this, since tools like NCover just run tests from the bin folder). Because of this, you will have to configure everything you want to copy, in addition to the DLL. The standard way to do this is to specify deployment elements in the .testrunconfig file. You can do this by going to the "Testing / Editing Test Configuration / Deployment Runs" section. You can use the "Add File ..." button to add a configuration file.

+1
source

Source: https://habr.com/ru/post/1347490/


All Articles