I have a very simple class with Watin test which is built and run nicely from Visual Studio.
Now I want to build it and launch with Nant. I’ve written the following nant .build file:
<?xml version="1.0"?>
<project name="WatinTests" default="build">
<property name="build.dir" value="c:WatinTests\bin\" />
<property name="project.rootdirectory" value="." />
<property name="solution.dir" value="."/>
<property name="solution.file" value="${solution.dir}/WatinTests.csproj"/>
<property name="build.configuration" value="debug" />
<property name="nant.settings.currentframework" value="net-4.0" />
<mkdir dir="${build.dir}" />
<target name="build">
<exec
program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
commandline="${solution.file} /t:Clean /p:Configuration=${build.configuration} /v:q"
workingdir="."
output="${build.dir}/WatinTests.dll" />
</target>
<target name="test" depends="build">
<nunit2>
<formatter type="Plain" />
<test assemblyname="${build.dir}WatinTests.dll" />
</nunit2>
</target>
</project>
First task is performed successfully – WatinTests.dll file goes to \bin directory.
But test is not launched. Here is the output:
Buildfile: file:///c:/WatinTests/nant.build Target framework:
Microsoft .NET Framework 4.0 Target(s) specified: build testbuild:
test:
BUILD FAILED
c:\WatinTests\nant.build(14,6): Failure executing test(s). If you
assembly is not built using NUnit version 2.6.0.12051, then ensure you
have redirected ass embly bindings. Consult the documentation of the
task for more information.
Could not load file or assembly ‘WatinTests.dll’ or one of its dependencies. An attempt was made to load a program with an incorrect
format.
Could not load file or assembly ‘WatinTests.dll’ or one of its dependencies. An attempt was made to load a program with an incorrect
format.
What is wrong here?
As mentioned in the Nant documentation, did you add the assembly binding redirection into your app.config :