Build/Test Issues

Usage of DeploymentItem attribute

Started by sholder on 7,474 views

I have a test which relies on being able to find files. I am using the TestContext.TestDeploymentDir to set the base directory where the structure will be located. I am also using the DeploymentItem attribute to tell VSTS that the items should be part of the test deployment, as well as set the Enable Deployment bit for the solution. The tests run successfully with VSTS and CodeRush Test Runner but do not in NCrunch.

<Edit>
Looks like CodeRush Test Runner is having an issue finding the resources also because it is now failing after a clean solution.
</Edit>

The error I get is a DirectoryNotFoundException on:

%USERPROFILE%\AppData\Local\NCrunch\4116\25\TestResults\1cb3ef5e-f7c3-4424-bb95-f910ea7ae16f\Out\Configurations\1234\configuration.js

I used ProcMon and found that the files are getting deployed to the following locations.

%USERPROFILE%\AppData\Local\NCrunch\4116\25\Absg.MyCubixx.FileSystemConfigurationProvider.Tests\Configurations\1234\configuration.js

and

%USERPROFILE%\AppData\Local\NCrunch\4116\25\Absg.MyCubixx.FileSystemConfigurationProvider.Tests\bin\Debug\Configurations\1234\configuration.js

Is there a better property to use to determine the base deployment directory? Or for that matter just a better method?

Regards,
Shane Holder

Edited

Hi Shane,

Thanks for reporting this. NCrunch does its best to emulate the deployment behaviour of MSTest, though many of the rules in this area are inconsistent and it wouldn't surprise me if there are a few gaps. You should be able to rely on the current directory being consistent with the deployment directory that has been created (Directory.GetCurrentDirectory()) - so I would consider using this. Are you able to share any of the code you use to determine the working directory of the configuration.js file during the execution of your test? This will help me with finding the compatibility gap and closing it in a future version.


Cheers,

Remco

Post a reply

Log in to reply.