Using a config file in Microsoft Unit Tests
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 n开发者_开发技巧eeded 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?
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.
set the config file to copy to the output directory in a post build
精彩评论