Unit Test Config Files

We store our database connection key in the application config file. Since many of our unit tests hit the database, we need to supply a config file. In NUnit, we just place a config file in the same directory as the NUnit project file and NUnit automatically uses that file. For example for a test project file of TestApp.nunit, we create a TestApp.config file.

How or where do we specify a unit test config file with R#?

0
4 comments
Avatar
Permanently deleted user

If I'm not wrong, you should [ut the config file by the DLL being tested.
Doesn't this work?

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Laurie Dvorak" <no_reply@jetbrains.com> wrote in message
news:2372063.1150409096485.JavaMail.itn@is.intellij.net...

We store our database connection key in the application config file.
Since many of our unit tests hit the database, we need to supply a config
file. In NUnit, we just place a config file in the same directory as the
NUnit project file and NUnit automatically uses that file. For example
for a test project file of TestApp.nunit, we create a TestApp.config file.

>

How or where do we specify a unit test config file with R#?



0
Avatar
Permanently deleted user

That works, thanks!!! We normally run using NUnit project files, so I forgot about DLL config files.

For anyone else reading this post, the config file name needs to be DllName.dll.config. The first time I tried Eugene's suggestion, I forgot to add the .dll in between the DLL name and the .config.

0
Avatar
Permanently deleted user

I also found I had to put a post-successful-compile build event (Right-Mouse on proj file... Properties) to copy the <dllname.dll>.config file to the target directory, since that's where, by default, it runs the tests:

XCOPY /Y /F ..\..\ContactMessaging.Testing.dll.config .

Message was edited by:
Jesse Wolfe

0
Avatar
Permanently deleted user

You can make the post build event more efficient by only copying the config file when it either doesn't exist or has changed. Here's an example of a similar post build event we use for this same purpose.


cd /D $(TargetDir)
XCOPY /M /Y /C /R $(SolutionDir)Resources\Libraries\recordManager.config
IF NOT EXIST recordManager.config COPY $(SolutionDir)Resources\Libraries\recordManager.config


HTH,

Sam

0

Please sign in to leave a comment.