I want the Trace, Console and Console Error outputs would be written into the common XML report file (for example into cad.UnitTests.xml). By default this info is not written in XML.
How can I do it? nunit-console.exe
has such parameters:
/output=STR File to receive test output (Short format: /out=STR)
/err=STR File to receive test error output
But I need to get it in the same XML file. I need it for both cases: nunit-console.exe
and nunit.exe
. Also, I looked the settings of GUI NUnit but found nothing.
My BAT file has such content:
:: run_me.bat
:: © Andrey Bushman, 2015
ECHO OFF
CD /D %~dp0
SET file_name=cad.UnitTests
:: Run NUnit tests
call "%NUNIT%\nunit-console.exe" ^
/out="%~dp0%file_name%_out.txt" ^
/err="%~dp0%file_name%_err.txt" ^
/trace=Verbose ^
/noshadow ^
/xml="%~dp0%file_name%.xml" ^
"%~dp0%file_name%.dll"
:: Get the HTML report of the unit testing
call "%ReportUnit%\ReportUnit.exe" ^
"%~dp0%file_name%.xml" ^
"%~dp0%file_name%.html"
But even if I use such command:
call "%NUNIT%\nunit-console.exe" ^
/out="%~dp0%file_name%_out.txt" ^
/err="%~dp0%file_name%_err.txt" ^
/noshadow ^
/xml="%~dp0%file_name%.xml" ^
"%~dp0%file_name%.dll"
then the Trace output is absent in both files (the "%~dp0%file_name%_out.txt" and "%~dp0%file_name%_err.txt").
I don't see of nunit-console.exe
option for Trace output redirection (something like /traceFile
). I see the /trace
parameter, but it has other purpose.
It is necessary for me, because I use the result XML for generation of HTML through the ReportUnit.exe. I want to see the detailed info in the HTML.
I can save the Trace output into TXT file in the code of my unit tests:
/* SetUpClass.cs
* © Andrey Bushman, 2015
*/
namespace Bushman.CAD.UnitTests {
using System;
using System.IO;
using System.Diagnostics;
using NUnit.Framework;
[SetUpFixture]
public class SetUpClass {
private TextWriterTraceListener listener = null;
[SetUp]
public void RunBeforeAnyTests() {
Stream traceFile = File.Create("trace_out.txt");
listener = new TextWriterTraceListener(traceFile);
Trace.Listeners.Add(listener);
}
[TearDown]
public void RunAfterAnyTests() {
listener.Flush();
}
}
}
But I still have a hope what I can to get this info in the XML file (which is generated by NUnit) through the "native" way of NUnit.