Daily Usage Issues

Files setup for deployment in TestSettings are not deployed

Started by Henriksen on 9,465 views

We have some files that need to be in the current directory when running the tests, among others the nihbernate.cfg.xml file.

We're using MSTest so what we've done is setting up deployment in the Test->Edit Test Settings -> Local (test.testsettings) and under the "Deployment" sheet, we've added the relevant files.

When using MS test runner or the ReSharper runner the files are deployed to (Solution)\TestResult\user_workspace 2012-01-25 10_46_59\Out (when using MS test runner or (Project)\bin\Debug\TestResult\user_workspace 2012-01-25 10_46_59\Out (when using the ReSharper test runner)

Those directories are also the current directory when using the respective test runners.

When running tests in NCrunch the current directory is C:\Users\user\AppData\Local\NCrunch\12884\98\TestResults\1a6f5bbd-85f2-4122-a27c-abb7065286a5\Out but the files specified for deployment in the Test settings are not there.

It would be preferable that NCrunch made sure to copy the relevant files from the Test Settings but in the meantime, how can I make sure that the relevant files are copied into the Out directory?
NCrunch doesn't support the use of MSTest deployment resources through the testsettings file, so no files that you specify here will be copied into the testing workspace (as you've described). There are two ways you can work around this:

1. Declare the files to be copied by using the DeploymentItem attribute on your tests, instead of in the config file (as NCrunch does support this)

2. Reference the files in their original location within your solution, using relative paths. Provided you have included the files within the NCrunch workspace using a .proj file, or using the 'AdditionalFilesToInclude' NCrunch config setting, the files should exist underneath the NCrunch workspace (which in your case is at C:\Users\user\AppData\Local\NCrunch\12884\98\). NCrunch will always store the files with the same relative path as they would be within your normal solution, so you can access them by referencing upwards from your test 'Out' directory ... for example: ..\..\..\ResourceFiles\myfile.txt. If your code is fully dependent on the files existing within the 'Out' directory, you could rig up an extra step in the test to copy the files there.

I hope this helps.


Cheers,

Remco

Post a reply

Log in to reply.