Build/Test Issues

NCrunch test fails to find an output file from a reference project

Started by Dirk Maegh on 1,657 views

Hi,

Today I ran into a unittest that ncrunch reported as failed on my machine.
I did not touch it and inspected the test runs in the cloud pipelines - they also did not fail.
So I investigated further, and ran the same test in Resharper unit test runner, it ran fine.
I investigated further. Running the same test by VS 2019 (latest version) Test Explorer also runs fine.

What failed on my machine was reading a xslt file, that lives in a referenced project - it has build action None, and Copy Always.
I noticed that my unittest project build output effectively contains the same file.
When I inspect the Resharper output directory, it contains the same files.
When I inspect the NCrunch output directory, it does not contain this file (nor a lot of other files), so maybe it makes sense that the file cannot be read when run by ncrunch.

Is this something you could fix please ?

Edited

Hi, thanks for posting.

To allow NCrunch to work with this structure, you need to turn on the copy referenced assemblies to workspace setting for the referencing project. This will tell NCrunch to make sure that the files in the build output directory of the referenced project are copied over when the referencing project is build.

There is a cost to using this setting, which is why it isn't enabled by default. Where possible, I would recommend you engineer your code in such a way that the setting isn't required. For example, if you have control over the search logic for the XSLT, perhaps try to find this file based on the assembly location of the project that contains it (i.e. GetType().Assembly.Location).
Thanks for your answer. It indeed fixed it straight away, simple and un-painfully ;)

Problem that I think is submerging here, is this feature is not obvious. I know it now, but in three months time, I will have forgotten about it, and the same question will rise again somewhere else.
But a question here fixes it real quick. Thanks again :)

Post a reply

Log in to reply.