iLemming
iLemming

Reputation: 36254

How to find path to content in a different project

I'm trying to write a test that actually has to use an executable that sits in output directory of another project, I referenced that "other project" in my test, now what? How do you access a file in output directory of "other project" ? File has BuildAction = Content and Copy to output directory = Copy Allways

System.Reflection.Assembly methods aren't helping

Upvotes: 1

Views: 90

Answers (1)

Chris Holwerda
Chris Holwerda

Reputation: 1255

Easiest way is to go to your "other" project's method you want to call and select "Create Unit Tests...".

Let it create the stub for you. You should get a chunk of code like below and it should add the reference and create a Test References folder with an YourApplication.accessor file in it.

    /// <summary>
    /// Your test
    ///</summary>
    [TestMethod()]
    [DeploymentItem("YourApplication.exe")]
    public void YourTest()
    {
        //your entry point that you want to call in the exe
        Program_Accessor.YourMethod();

        //Your assert test here
    }

Copy the DeploymentItem attribute to your test, wire up your method call, and try running the test.

Upvotes: 1

Related Questions