Junit Pass/Fail reports in SonarQube using Junit xml - junit

Can we have Junit test reports (not coverage) Test Pass / Fail Percentage report on Sonar Qube Dashboard (From my understanding, it should appear in the 'measures' tab) from the Junit report xml generated from Build ?
What is the step by step procedure to get Unit Test execution (Pass/Fail) reports.

You need to set sonar.tests path in sonar-project.properties file. It should be the directory where your test case report xml file is placed.
(https://docs.sonarqube.org/display/SONAR/Analysis+Parameters)
Once you will set the correct path, then you will be able to see the reports at Messures>Coverage.

Everything is clearly documented on the "Code Coverage by Unit Tests for Java Project" documentation page.
This will create metrics that you can indeed browse on the "Measures" page:

Related

FitNesse: How to send tests execution reports from Jenkins to an endpoint in JSON format?

I have a task to send reports of periodic execution of FitNesse tests to some specific endpoint in some specific JSON format.
I set periodic execution of tests in Jenkins properties and saving it in XML, but now I need to parse information about results of it.
It cannot be just step in "after build" property in Jenkins (or can, but I don't know a plugin for it), but what it would be and how I can do this?
Especially, I don't need information about the test, only general moments like date of the test, pass rate, status, name of the project, etc.
I think the best way to solve this is to make a script that parses the XML file, and creates the required JSON file. We normally use python scripts for this.
If you need certain generic information of the build in the script, like build number, you can pass this to your script using the Jenkins environments.
To call the script just add a batch or shell step, and place it below your fitnesse build step, to make sure the XML is generated before calling the script.
FitNesse comes with a jUnit runner which allows you to execute a test/suite. If you create a test class annotated with #RunWith(FitNesseRunner.class) and include its execution in a Jenkins Maven job (where the jUnit class is executed by either surefire or failsafe plugin), the outcome of the tests executed will be picked up automatically by Jenkins, just like it picks up other/regular jUnit tests (as surefire or failsafe will include them in their XML reports and Jenkins will pick these up).
You can find a sample Maven FitNesse project using (a slightly customised version of) this approach at https://github.com/fhoeben/sample-fitnesse-project. How to run the tests on Jenkins is described at https://github.com/fhoeben/hsac-fitnesse-fixtures#to-run-the-tests-on-a-build-server:
Have the build server checkout the project and execute mvn clean test-compile failsafe:integration-test. The result in JUnit XML results can be found in: target/failsafe-reports (Jenkins will pick these up automatically for a Maven job)
You indicate you don't need the HTML results, but they will be made available. They can be found in: target/fitnesse-results/index.html, and you could choose to use the 'HTML Publisher' Jenkins plugin to link to them from each build.

generating reports in Jenkins

Need to run a job in Jenkins after successfully running the tests it needs to perform as post-build action for generating test reports
For this i have configured
Publish JUnit test result report
In the field
Test Report XMLs: continuum/*/target/surefire-reports/*TestSuite.xml
'continuum/*/target/surefire-reports/TestSuite.xml' doesn't match anything: 'continuum' exists but not 'continuum//target/surefire-reports/*TestSuite.xml'
Can you please help me out in resolving the error....??
I assume you have an 'Execute JUnit tests' Build step. This will produce a JUnit XML file to a location you specify, say, TestOutput/junitresults.xml.
In the 'Publish JUnit test result report' Post Build step you just need to specify TestOutput/junitresults.xml.
As long as your tests executed and produced the output file the Post Build step won't fail to publish it, whether the tests failed or not.
You shouldn't be trying to publish files in the surefire-reports directory unless that it where you told JUnit to write its output file. Normally you wouldn't.
If you want to make it even simpler just tell JUnit to write its output file to the Jenkins WORKSPACE root by removing the TestOutput/ and just specify junitresults.xml.

Build step 'Publish JUnit test result report' changed build result to FAILURE

I'm stuck configuring tests for Jenkins. In the Publish JUnit test result report I have test-reports/*.xml but I'm getting the error:
'test-reports/*.xml' doesn't match anything: 'test-reports' exists but not 'test-reports/*.xml'
When I try */.xml I get:
Did not manage to validate **/*.xml (may be too slow)
When I throw an .xml file into test-reports folder manually it is deleted after the build.
What do?
It might actually be an issue with XCode. We figured out that it was actually skipping the application tests and it just wasn't evident anywhere on Jenkins' console output.

Creating an HTML report with embedded screenshots of failed JUnit tests

I've put together a custom JUnit runner that saves a screenshot when a WebDriver test fails.
I'm using Maven's failsafe plugin to create reports of the integration tests and TeamCity is our CI server.
I know TeamCity supports custom reports, but I don't know how I'd embed the image files into an HTML page (or pages) with references to the relevant tests.
What would be a good method to integrate the screenshots into the test report?
Is there a Maven plugin that'll do the job?
Maybe Allure-report would suit for your purpose. It allows to create a nice report that contains different attachments, including screenshots. Moreover it has JUnit integration and Teamcity plugin, so it fully covers your use-case.
Unfortunately there is no way to simply change the reports cause they are generated by the maven-report-plugin which can't be simply changed.
What you can try is to create a separate folder and create a link via the site.xml descriptor.
You can try maven-cobertura-plugin. Including this in your build will generate a HTML report of all the test case success, failure and coverage. Hope this helps....

Parsing JUnit XML with Hudson

I'm using Jasmine-reporters with Jasmine to output a bunch of JUnitXML format files that I need Hudson to parse for me and report on success/failure. Does anybody know how I would ask Hudson to go test a bunch of XML as part of the build process? Thanks!
In the job's "Post-build Actions", there should be a check box to "Publish JUnit test result report". You can put an ant-glob expression (as if you were writing an "includes" element) to match your xml files. I'm basing this on what I see in my Jenkins server; Hudson should be equivalent for your question.