Converting .log file to Sonarqube readable file - unit-testing

I have a .log file which gives the minimum information about the unit test case execution. The log contains, the date, pass, fail information, error message if any. I need to upload this to sonar qube and see the unit test case result. Just the unit test case result. that would be total number of test cases, the execution results. From this I need to get the unit test case coverage. How can I get a dash board in sonar qube with this .log file? Should I convert the .log file to XML file in Nunit format? Or do we have a simple format for sonarqube?

What you're looking for is the Generic Test Data format. Convert your log file into the XML format described in the docs, and use the sonar.coverageReportPaths property to specify the path to the file.

You should have a look at the Generic Test Data feature.

Related

How to document test cases of a program with complex input

I need to document tests that execute a program which takes a xml file as input and then generates multiple .c and .xml files as output.
The existing 300 tests are implemented as JUnit test cases and I started documenting them with doxygen.
The documentation should help to save time when it comes to the questions:
Which test cases have to be modified when a specific feature is modified?
Are all features of the program tested in at least one test case?
My first ideas was to use the classification tree method. The result would look like this example picture:
The program to test uses only a few boolean parameters but also a XML file which is the main input. This XML file contains different lists of nodes and a lot of invariants have to be checked by the program when generating the output .c and .xml files. As part of the tests the input XML file and the generated files are also parsed and compared.
To apply the classification tree method equivalence classes have to be found. In my case all possible contents of the input XML file have to be classified.
How could a structured way of working through all of these possible XML nodes look like? This seems to be a complicated task and I want to proceed in an efficient way.
Maybe using the classification tree method is also not the best choice for this task. Are there other/better options?

Can the Karma unit test framework write a file to the file system?

I have a need to be able to write out a text file to the file system from inside a Karma test. I want a test to spit out an HTML file that provides a visual representation of the results of a complex test. Certainly I can read files by specifying test fixtures in karma.conf.js, but as yet I've found no way to output anything to disk. An alternative is to scrape output off the console log and paste it into a file, but that seems awfully clunky.
Any ideas?
I believe that Praveen's answer in the comments, to look at https://www.npmjs.com/package/karma-log-reporter as a starting point,
is a decent answer to my question.

How to test a xml files during maven(3) test phase

Is there any way to perform a basic test/unittest for a xml file included in a module?
E.g. I like to "lint" test my persistence.xml or check if the schema to a xml-file is valid.
What about using the xml-maven-plugin
It could be that the links will become invalid cause codehaus is shutting down it's services so you can take a look at https://github.com/mojohaus/xml-maven-plugin.

How to keep the unit test output in Jenkins

We have managed to have Jenkins correctly parse our XML output from our tests and also included the error information, when there is one. So that it is possible to see, directly in the TestCase in Jenkins the error that occurred.
What we would like to do is to have Jenkins keep a log output, which is basically the console output, associated with each case. This would enable anyone to see the actual console output of each test case, failed or not.
I haven't seen a way to do this.
* EDIT *
Clarification - I want to be able to see the actual test output directly in the Jenkins interface, the same way it does when there is an error, but for the whole output. I don't want only Jenkins to keep the file as artifact.
* END OF EDIT *
Anyone can help us on this?
In the Publish JUnit test result report (Post-build Actions) tick the Retain long standard output/error checkbox.
If checked, any standard output or error from a test suite will be
retained in the test results after the build completes. (This refers
only to additional messages printed to console, not to a failure stack
trace.) Such output is always kept if the test failed, but by default
lengthy output from passing tests is truncated to save space. Check
this option if you need to see every log message from even passing
tests, but beware that Jenkins's memory consumption can substantially
increase as a result, even if you never look at the test results!
This is simple to do - just ensure that the output file is included in the list of artifacts for that job and it will be archived according to the configuration for that job.
Not sure if you have solve it yet, but I just did something similar using Android and Jenkins.
What I did was using the http://code.google.com/p/the-missing-android-xml-junit-test-runner/ to run the tests in the Android emulator. This will create the necessary JUnit formatted XML files, on the emulator file system.
Afterwards, simply use 'adb pull' to copy the file over, and configure the Jenkin to parse the results. You can also artifact the XML files if necessary.
If you simply want to display the content of the result in the log, you can use 'Execute Shell' command to print it out to the console, where it will be captured in the log file.
Since Jenkins 1.386 there was a change mentioned to Retain long standard output/error in each build configuration. So you just have to check the checkbox in the post-build actions.
http://hudson-ci.org/changelog.html#v1.386
When using a declarative pipeline, you can do it like so:
junit testResults: '**/build/test-results/*/*.xml', keepLongStdio: true
See the documentation:
If checked, the default behavior of failing a build on missing test result files or empty test results is changed to not affect the status of the build. Please note that this setting make it harder to spot misconfigured jobs or build failures where the test tool does not exit with an error code when not producing test report files.

JUnit Report single page XSLT for email

I have a Junit process that runs a bunch of data integrity tests every night, and I would like to have it email the results in a nicely formatted HTML email. The issue is the HTML formatter built into JUnit uses frames and an external stylesheet so it is not appropriate for email. The plain formatter has the results buried in the midst of a bunch of otherwise worthless data.
I thought it would be simple to find a XSLT stylesheet that formatted the XML output into an email-friendly format, but after a couple hours of googling, I have not been able to find one. If any of you have a email-friendly Junit formatter, I'd be eternally grateful.
From http://ant.apache.org/manual/Tasks/junitreport.html
Ant assumes the following concerning
the frames and noframes formats :
The frames format uses a stylesheet
which is generating output only by
redirecting.
The noframes format does not use
redirecting and generates one file
called junit-noframes.html.
Custom versions of junit-frames.xsl or
junit-noframes.xsl must adhere to the
above conventions.
Edit: The only web aviable source in here
Use the one that Ant's <junitreport> to create the HTML report and email that.