views:

66

answers:

0

I have a number of test classes and methods that copy a particular directory like so:

[TestClass, DeploymentItem("LanguageData", "LanguageData")]
public class OcrTests
{
    [TestMethod]
    public void Can_Capture_Field()
    {
        // some code that expects the LanguageData directory to be in the test results Out directory
    }

    // etc
}

[TestClass]
public class OcrBuilderTests
{
    [TestMethod, DeploymentItem("LanguageData", "LanguageData")]
    public void Can_Build_Specific_Ocr_Engine_Implementation()
    {
        // some more code that expects the LanguageData directory to be in the test results Out directory
    }

    // etc
}

Those tests are in a single assembly and all the files in the LangaugeData directory have their Copy to Output Directory set to Copy Always.

It all works fine and the directory is copied to the test results Out directory as long as I only have that one test assembly loaded into the solution or that's the only assembly I run tests from (i.e. run tests only in current context/class).

As soon as I add a second assembly and run all the tests in the solution then that directory no longer gets copied, but any other DeploymentItems that are just individual files seem to get copied fine.

The tests themselves all still run, but the ones that depend on that directory crash. Presumably that's because MSTest can't find the directory - perhaps it's expecting it to be in the build directory of one of the other test assemblies?

Any ideas what it is about multiple test projects that's preventing the copy, and what I can do to get around it, short of adding every single file in that directory as an individual DeploymentItem?