Build/Test Issues

DeploymentItem with Environment Variable not working

Started by ronjacobs on 9,022 views

I've just tried using NCrunch for the first time. My project currently builds and passes all unit tests from Visual Studio.

However, when NCrunch runs the tests I get many test failures due to deployment items not being deployed.

It appears that MSTest DeploymentItem is supported. However I wonder if it could be because of the environment variable I use.

[DeploymentItem(@"%LABDIR%\Microsoft.Activities.Extensions\Microsoft.Activities.Extensions.Tests\ServiceExtensionTest.xamlx")]

I use the %LABDIR% variable because DeploymentItem uses either a full path or relative to the solution file path. But in my case, this test file is included in multiple solution files so I can't use a relative path. I use the %LABDIR% variable to make sure the deployment item is found regardless of the solution path.

Could that be the issue?
As a quick test I replaced the environment variable with the actual path and the test is now passing.

Please make the DeploymentItem expand the environment variable
Here is my workaround

#if NCRUNCH
/// <summary>
/// The Lab directory
/// </summary>
/// <remarks>
/// NCrunch does not expand environment variables
/// </remarks>
internal const string Labdir = @"D:\wf.codeplex.com\src\wf\labs";
#else
/// <summary>
/// The test projects folder.
/// </summary>
internal const string Labdir = "%LABDIR%";
#endif
Hi, thanks for posting!

It's true that NCrunch currently doesn't parse environment variables specified in the DeploymentItem. Thanks for making me aware of this issue, I'll note it down for a fix in a future revision.


Cheers,

Remco
For anyone interested, NCrunch 1.41b has just been released including a fix for the above issue. NCrunch should now automatically resolve and handle deployment items making use of environment variables.

Post a reply

Log in to reply.