2

Currently for a number of my unit tests I require that some configuration be pulled from a file. Initially I thought I only needed to add Test Settings to my unit testing project and configure this in Test Settings->Deployment. I added my config file here but my unit tests were still complaining that they couldn't find this config file. Finally I found that I needed to add the [DeploymentItem("Test.config")] attribute to any of my unit test classes that needed this.

Is this how it's supposed to be done? It seems like I should not have to use the DeploymentItem attribute. Am I doing something wrong here?

2 Answers 2

2

Do you mean that your code under test requires a config file? Then you can add a regular app.config to your unit tests. Well in all other cases you can use that as well.

Sign up to request clarification or add additional context in comments.

1 Comment

It's not an app.config file that the tests require. It's a custom config file.
1

set the config file to copy to the output directory in a post build

2 Comments

This seems like it may be a better way of doing it than I currently am but I'm still wondering why this doesn't work when I set the config file up as a Deployment item in the test settings.
Can you elaborate on this answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.