Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can you use "external" configuration files (i.e. with configSource) with an MSTest unit test project?
    primarykey
    data
    text
    <p>For simplicity, I generally split a lot of my configuration (i.e. the contents of app.config and web.config) out into separate .config files, and then reference them from the main config file using the 'configSource' attribute. For example:</p> <pre><code>&lt;appSettings configSource="appSettings.config"/&gt; </code></pre> <p>and then placing all of the key/value pairs in that appSettings.config file instead of having this in-line in the main config file:</p> <pre><code>&lt;appSettings&gt; &lt;add key="FirstKey" value="FirstValue"/&gt; &lt;add key="SecondKey" value="SecondValue"/&gt; ... &lt;/appSettings&gt; </code></pre> <p>This typically works great with the application itself, but I run into problems when attempting to write unit tests that, for whatever reason, need to get at some value from a configuration section that is stored in one of these external files. (I understand that most of these would likley be considered "integration tests", as they are relying on the Configuration system, and I do have "pure unit tests" as well, but those are the not the problem. I'm really looking to test that these configuration values are retrieved correctly and impact behavior in the correct way).</p> <p>Due to how MSTest compiles and copies the output to obfuscated-looking folders that are different from every test run (rather than to the 'bin' folder like you might think), it never seems to be able to find those external files while the tests are executing. I've tried messing around with post build actions to make this work but with no luck. Is there a way to have these external files copied over into the correct output folder at run time?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload