I'm currently trying to run MSTest.exe from NCover, but I believe the question could apply generally to running MSTest.exe from the command line.
If I have the "/noisolation" argument, then MSTest.exe appears to find and use the app.config as expected. Without it, NCover doesn't capture any coverage information. From my research so far, it seems NCover needs /noisolation. So the question is how to get my *.config files to work when that argument is passed.
My NCover settings are:
Application to Profile
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe
Working Folder
C:\Documents and Settings\MyProfile\My Documents\Visual Studio 2008\Projects\XYZ\XYZ.CoreTest\bin\Debug
Application arguments
/noisolation /testcontainer:"C:\Documents and Settings\MyProfile\My Documents\Visual Studio 2008\Projects\XYZ\XYZ.CoreTest\bin\Debug\XYZ.CoreTest.dll"
Update: I added a trace showing that my config is (not surprisingly) trying to read from "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe.Config".
Update 2: If at all possible, I don't want to edit MSTest.exe.Config. That just isn't terribly portable.
In Solution Explorer, right-click the project node, and then select Add > New Item. The Add New Item dialog box appears. Expand Installed > Visual C# Items. In the middle pane, select the Application Configuration File template.
Right-click on the project, select Add->New Item..., then select "Application Configuration File" from the list of possible items. Show activity on this post. It would be a template in the templates directory of Visual Studio.
The Machine. config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ directory.
config files in the %SystemRoot%\Microsoft.NET\Framework\<version>\CONFIG directory, but you will not see those default settings here. Application-level or directory-level Web. config files only need to be created if you want to override the inherited default settings or add to collection elements like httpHandlers.
From Craig Stuntz in a comment at link text
How to do this with MSTest.
In Solution Explorer, right-click the Solution (not the Project).
Click Add, New Item
In Categories, select Test Run Configuration
Now choose the Test Run Configuration item and add it to your project
In Solution Explorer, double-click the Test Run Configuration you just created
Click the Deployment item
Add your config file as a deployed file (or deploy the entire folder which contains it, if appropriate)
This took me a little while to figure out, but I'm in a similar situation and it does work for me.
In visual studio, mark the App.config file to property to CopyAlways. (right click on file, choose properties to get to the property panel)
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