Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTest.exe not finding app.config

Tags:

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.

like image 619
Larsenal Avatar asked Jan 27 '09 19:01

Larsenal


People also ask

How can add app config file in Visual Studio code?

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.

Where is app config file in Visual Studio 2010?

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.

Where is .NET config file?

The Machine. config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ directory.

How do I add web config to Windows app?

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.


2 Answers

From Craig Stuntz in a comment at link text

How to do this with MSTest.

  1. In Solution Explorer, right-click the Solution (not the Project).

  2. Click Add, New Item

  3. In Categories, select Test Run Configuration

  4. Now choose the Test Run Configuration item and add it to your project

  5. In Solution Explorer, double-click the Test Run Configuration you just created

  6. Click the Deployment item

  7. 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.

like image 139
Lucas B Avatar answered Sep 24 '22 09:09

Lucas B


In visual studio, mark the App.config file to property to CopyAlways. (right click on file, choose properties to get to the property panel)

like image 40
oglester Avatar answered Sep 20 '22 09:09

oglester