Disconnecting unit tests to another project

I used to have Tests folders in my main project where the unit test had this line of code:

Foo foo = new Foo(Environment.CurrentDirectory + @"\XML\FooData.xml" );

      

I have an XML directory in a Foo project that has FooData.xml

In the post build event of my projects I have the following line copy "$ (ProjectDir) Foo \ Currencies.xml" "$ (TargetDir) \ XML"

Now I have split all the unit tests into other projects to separate them and now I am getting the following error while running these unit tests.

Could not find part of path 'C: \ svncheckout \ Foo.Tests \ bin \ Debug \ XML \ FooData.xml'

0


source to share


3 answers


Instead of doing a post-build step, can't you just make it "content" in Visual Studio by telling it to copy it to the target directory? I usually either do this or make it an embedded resource and use Streams and Assembly.GetManifestResourceStream.



+4


source


I believe you need to update the post build event for the Foo.Tests project:



"$ (ProjectDir) Foo.Test \ Currencies.xml" "$ (TargetDir) \ XML"

+1


source


You can also put the full xml path in your test modules app.config

0


source







All Articles