How to print an NUnit test run's XML file as a nice-looking report on the command line? - nunit

I have a suite of NUnit tests. When they finish, I get a TestResults.xml file. This file is very large and dense; I'd like to be able to peruse a simple human-readable report of the underlying results. I'm led to believe that the provided nunit-console program can do that, but I can't figure out how.
How can I print the information described by TestResults.xml with nunit-console?
Note that running the tests is not the problem; my problem is figuring out how to display the results on the command-line. I can't change how the tests are run, but I can do whatever I want with the results file.

The Test Result file isn't intended to be human-readable, except when used for debugging. It's a source for all the data about a test run from which human-readable reports may be generated.
There are two ways to generate a report
As a part of the test run itself.
After the run is finished, using the test result xml file.
Reports generated as part of the test run require a report writing extension. You would write such an extension following the documentation to produce the report in whatever format you require, like text or html, and give it a unique tag likemyreport.
You would install your extension and could then run the console runner including an option like
--result:somefile.html;format=myreport
As you may guess, creating your own extension is a relatively advanced use of NUnit.
Another option, if you are familiar with XSLT processing, is to use the built-in report format user, together with an XSLT transform. In that case, the option is something like
--result:somefile.html;transform=mytransform.xslt
You can also produce a report after the run is finished using the XML output file. The NUnit console program is not used in this case. You must use some standard program for creating reports from NUnit output (or a generic program taking XSLT transforms) or write your own program.

Related

WinDbg scripting - how to delete a file?

I'm working with an existing framework of WinDbg scripts that go through a series of test scripts Test1.txt, Test2.txt, etc., which are generated by C++ code and which output results.
For example a chunk of one of the test scripts would be,
.if (($spat(#"${var}","18300.000000")==1))
{
.logappend C:\Tests\TestResults.txt
.printf "TestNumber=\t1\tExpected=\t18300.000000\tActual=\t%.6f\t******PASSED******\n",poi(poi(#$t2+#$t6)+0x10)
.logclose
}
I'm trying to add functionality that will create a file whose name displays the current # of the test being run, so that users can see their progress without needing to open a file.
My thought process was that I would set up the script generator, so that at the start of Test #N, it would add a line to the script to create a file 'currentlyRunningTestN.txt', and at the end of Test #N, it would add a line to the script to delete that file. However, I don't see any delete function in the WinDbg meta command glossary: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/meta-commands, or in the list of supported C functions like printf. Am I just missing something, or is deleting files not supported by WinDbg (or equivalently renaming files, which would also serve my purpose?) If deleting/renaming don't work, is there another way to achieve the functionality I'm looking for?
With the .shell command, you can execute any DOS-like command. Although I never tried deleting a file, it should be possible.
As you may have noticed, WinDbg scripting does not always work on first attempt, please make sure your scripting will not result in a big data loss on your customer's PC whilst deleting files.

Is it possible to suppress Run Settings output by nunit console?

NUnit console outputs run settings, which include the Test Parameters. I do not want it displayed. Is it possible? I use nunit3-console.
There are no options to change the default console text output, which is aimed at immediate developer feedback rather than reporting. Choices for you would be
Direct the output to a text file and edit it, perhaps automatically.
Create your own report from the XML result file, which contains all the necessary components. You can do this either by writing a resfoundult writer extension to the engine or creating an XSL transform that produces the result you want. I've generally found it best to just pick the technology (C# vs XSLT) that you most enjoy. :-)

How to pass arguments from UFT to command line

I am trying to run tests in UFT by running a .vbs file. I am also passing arguments through command line. .vbs file reads the arguments and sets the environment variable of UFT. Hence, I can read them inside UFT.
qtApp.Test.Environment.Value("First_Argument") = WScript.Arguments.Item(0)
qtApp.Test.Environment.Value("Second_Argument") = WScript.Arguments.Item(1)
After that, I want to get a number as an output from UFT because I will use that output to pass it to the next command in command line.
The Test Parameters Object can be a way , more detailed in the Automation Object Documentation
You will have to define the TestParameters of the TestCase from the UFT IDE(manually) there is no way to define them automatically. If you declare them as in and out type, and change their value as a part of a Test Case, you would be able to read it afterwards from the vbs (Do not open a new Test Case until you did not read out the preferred values)
Although this is a working (and standard) way for exchanging parameters between the driver script and the TA Robot(UFT) I would advise you to use a simple file based way of doing this - managing test parameters can be very time consuming.
Tell the script via an Environment variable the path of the xml / json or simple text file where you expect the results to be written and when the test is done, read the content of the file (assuming the test will write into that file)
The plain old file way should not be underestimated especially in such circumstances.

Custom batch file creation for building code generated from Simulink Models

How can I create a custom batch file for my code generated from Simulink model ?
I can see, if I edit and change my template make file from Configuration Parameter Dialog box, I can get the desired make file.
But I want a custom .bat file too, that calls this make file along with other commands.
I have some environment variable to set and run couple of scripts in .bat file, before compilation begins. Based on these outputs from script the code is to be compiled and linked.
Using Matlab Version: 2012b
Create a STF_wrap_make_cmd_hook that generates your desired modelname.bat file as shown in the example code
here (mathworks login necessary).
You will probably also need to write your own make_yourtarget.m file and edit the make command field shown in your screenshot to use that one instead of make_rtw.
Other hooks into the build process are described here, perhaps the 'before_make' will also be useful.

excel ant selenium test

I have testcases in an excel file.
A java program accesses that, and I run them on a browser using selenium RC.
Now, when I use ANT to generate an HTML report, it treats the entire thing as 1 test case.
is there a way to generate different test case reports in the same html ouput file?
Use different test cases to access different part of your excel sheets.It might be repeatable to you but this is the only way if you want ant or junit to consider it different test cases.
OR
Right your own code for generating your customized reports in whatever format you want html or excel.