Come eseguire i test NUnit v2.4.8 con NAnt 0.86 beta?
-
09-06-2019 - |
Domanda
Recentemente ho provato a utilizzare NAnt (beta 0.86.2962.0) per eseguire alcuni unit test compilati con l'ultima versione stabile di NUnit (v2.4.8) senza alcun successo.
L'errore che ottengo è il seguente:
[nunit2] L'assembly "C:\Dev\MySample\bin ests\My.Sample.Tests.dll" non contiene test.
Naturalmente, l'assembly contiene test che posso eseguire da qualsiasi runner, come NUnit one, TestDriven o Resharper.Vorrei utilizzare l'attività <nunit2> e non direttamente quella <exec>, ma mi chiedo se sia ancora possibile, anche utilizzando i file app.config per associare le versioni dell'assembly.
Soluzione
Non riesco a ricordare il motivo, ma ho rinunciato a utilizzare l'attività <nunit2> e ho utilizzato felicemente l'attività <exec> e nunit-console.exe.Se può essere d'aiuto, ecco il mio obiettivo di prova che esegue NUnit e FxCop.Tieni presente che li salta se i file eseguibili non si trovano nel percorso di Windows.
<target name="test" description="Run unit tests" depends="build">
<property name="windows-path" value="${string::to-lower(environment::get-variable('PATH'))}"/>
<property name="nunit-in-path"
value="${string::contains(windows-path, 'nunit')}"/>
<echo message="Tests skipped because no NUnit folder was found in the Windows path."
unless="${nunit-in-path}"/>
<exec program="nunit-console.exe" if="${nunit-in-path}">
<arg file="../MyProject/MyProjectTest.nunit"/>
</exec>
<property name="fxcop-in-path"
value="${string::contains(windows-path, 'fxcop')}"/>
<echo message="FxCop skipped because no FxCop folder was found in the Windows path."
unless="${fxcop-in-path}"/>
<fxcop projectFile="../MyProject/MyProject.fxcop" directOutputToConsole="true"
failOnAnalysisError="true" if="${fxcop-in-path}"/>
</target>