Thursday, March 22, 2007

If you are stuck using MSTest as your unit testing framework you may run into problems if any of your tests depend on external files.

MSTest creates a TestResults directory:

image001

A directory made up of your login name, computer name and a timestamp:

image002

and a In and an Out directory:

image003

 MSTest then copies all referenced assemblies to the Out directory and runs the tests in that directory. The problem is that MSTest does not recognize any XML configuration files (besides App.config) as dependencies and they are not copied to the Out directory so your test fails.

To remedy this you need to specify your external dependency as a deployment item in an attribute at the beginning of your test and specify the path to the deployment item:

[TestMethod]
[DeploymentItem("WindsorTestConfiguration.xml")]
public void ShouldUseDependencies()
{
    IWindsorContainer container = new WindsorContainer(new XmlInterpreter(@"WindsorTestConfiguration.xml"));
    Assert.IsNotNull(container);
}
Thursday, March 22, 2007 5:42:51 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: