zeal
zeal

Reputation: 475

How to set the result folder using command line parameter to nunit-console?

I am trying to run NUnit tests from command line and trying to save the results under TestResults folder. I have tried using following commands, but nothing has created the test results under intended folder. Rather the test results got created under the current running folder only!

cmd /k nunit3-console.exe test\bin\Debug\test.dll --where cat=test  --labels=All --work=TestResults --out=TestResult.txt --result=TestResult.xml;format=nunit2

cmd /k nunit3-console.exe test\bin\Debug\test.dll --where cat=test  --labels=All --work=TestResults --out=TestResults\TestResult.txt --result=TestResults\TestResult.xml;format=nunit2

cmd /k nunit3-console.exe test\bin\Debug\test.dll --where cat=test  --labels=All --out=TestResults\TestResult.txt --result=TestResults\TestResult.xml;format=nunit2

Likewise I have also tried changing the default test result filename from TestResult.xml & TestResult.txt to Sample.xml & Sample.txt by updating the --result & --out parameters, but no luck.

Upvotes: 1

Views: 4085

Answers (3)

Henryk Budzinski
Henryk Budzinski

Reputation: 1293

What you are looking for is the --work option.

Ex.: nunit3-console ./bin/release/myproject.dll --work=./MyTestFolder

The path of your test will be ./MyTestFolder/TestResult.xml

Upvotes: 1

zeal
zeal

Reputation: 475

Ohh my bad :)

I was missing double == after CAT which caused this issue.

cmd /k nunit3-console.exe test\bin\Debug\test.dll --where cat==test --labels=All --work=TestResults --out=TestResult.txt --result=TestResult.xml;format=nunit2

Above one fixed my issue and works perfectly fine.

Upvotes: 1

Charlie
Charlie

Reputation: 13681

The --out option has been around for a long time. It causes any output from the test, which would normally go to the console to be written to the file specified.

The --result option replaces the old NUnit V2 --xml option, and indicates where an XML output file should be written.

I think your problem arises from the fact that your tests produce no output "which would normally go to the console." That's because NUnit 3 sends almost all test output to the XML result file. The only console output that is produced is output written to stderr or created using TestContext.Error or TestContext.Progress.

It's possible to imagine a change to NUnit whereby use of --out would stop the output from being incorporated in the XML file, but that would be breaking for a lot of people.

Bottom line: once the output was added to the XML result file, the --out parameter became somewhat useless. :-(

Upvotes: 1

Related Questions