Search code examples
xmlseleniumvisual-studio-2015nunit

N Log Test Output to XML Format?


Forgive me for the general ness of the question but can someone point me to some documentation or offer advice on how to receive N Log Test Output from N Unit in an xml format. The reason I am asking is I want to convert this xml over to HTML using Report Unit but after I run my tests all I receive is a log file and I keep reading online about people who have their N Unit Test Results generated out to XML.

For example here is a test I have successfully ran in visual studio using N Unit.enter image description here

Here is my test case in which I have used the Logger Class from N Log enter image description here

But all I am getting is a txt file with my log statment in it even though I have tried configuring the NLog.Config file with the proper xml.enter image description here enter image description here

If you notice the NLog Config file I have tried updating the filename from ".log" to xml but that did not work either. I apologize for the scatteredness of the question but am I missing something basic? Shouldn't n unit tests be generating an xml result?

UPDATE: After getting clarifiaction please see below:

I have now access nunit3-console from the command line can you please advise what i Need to do from here to run specific tests to generate the xml file? enter image description here


Solution

  • First, NLog has nothing to do with NUnit even though they both start with N. The Test.log file will just contain any logging that you create. NUnit produces a TestResult.xml file with the test results, but AFAIK, the Visual Studio test adapter does not create the TestResult.xml.

    In order to create TestResult.xml, run your tests from the command line using nunit3-console.exe. You do this by going to your bin directory from the command line and passing your test.dll to the NUnit console.

    C:\src\MySolution\MyTestProject\bin\Debug> "C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" MyTestProject.dll

    This will run all tests in your project and TestResult.xml will be written out to that directory at the end of the test run. For more info, see the help for NUnit Console

    If you have further questions, add a comment I and I will update the answer for you.