I have started using Qunit to test my JS code. I am looking into JSCoverage to generate the coverage reports later. We have a CI server (Jenkins) which already do a few things with our PHP code and I was wondering if anyone can comment on how I can integrate the report from my Qunit and JSCoverage into Jenkins
Thanks
Sparsh
QUnit: use QUnit API to generate junit XML files. Here's a sample.
In Post-build Actions for your job you then check Publish JUnit test result report and specify your junit XML files (or their file pattern). Jenkins will then mark builds that have failed tests as unstable and produce a nice trend graph of successful/failing tests.
A few more details, for those actually attempting this:
Putting together QUnit and Jenkins
If you want to run QUnit and publish the results in Jenkins, you'll need to do the following:
Step 1: Getting QUnit to generate an XML file compatible with JUnit.
If you're using Apache Ant, this question explains how to get
QUnit to generate XML.
If not, you can use Grunt and
grunt-qunit-junit, together with grunt-contrib-qunit, to
run your .html tests.
And if you're not into either Ant or Grunt, here is
a script for PhantomJS to run your tests directly and produce
JUnit-style XML.
Step 2: Processing that XML file
This is the easy step - look in "Post-build Actions" for your job in Jenkins, and add the path to the XML file.
Related
I have a multi-module project and I am using JaCoCo plugin to generate coverage reports. I followed this blog to create a new module(let's call it project-coverage) and then added the dependencies there and then use the report-aggregate goal of jacoco to create the aggregated report.
At the end of the build I have an XML file under project-coverage/target/site/jacoco-aggregate/jacoco.xml
How can I take this XML and export it into Jenkins? I know there is a plugin support for Jacoco in Jenkins but I am not sure how can I use this XML report and not exec files to report the coverage in Jenkins.
I know there is a plugin support for Jacoco in Jenkins but I am not sure how can I use this XML report and not exec files to report the coverage in Jenkins.
According to https://www.jacoco.org/jacoco/trunk/doc/integrations.html there are at least two plugins for Jenkins. And according to the documentation of these plugins
https://plugins.jenkins.io/jacoco/ consumes exec
https://plugins.jenkins.io/code-coverage-api/ consumes XML
i have 2 test reports. One for backend i.e. junit and one for front end i.e. karma.
i have to publish test result to jenkins. For junit there is plugin. but for karma there is not.
What can be used.
As of now i tried using junit and xunit to publish the report. But what jenkins is doing here is -- "It is merging both the result reports into a single trend graph."
As noted, you can get Karma to publish in JUnit format.
Alternatively, if it can output HTML, you can publish those: https://jenkins.io/doc/pipeline/steps/htmlpublisher/
Karma is a test runner for JavaScript. (for angular that runs jasmine test cases)
For Karma, you can use "karma-junit-reporter" which will generate an XML file of test cases and then use publish JUnit reporter from post-build action and give path of that XML file
How to generate Html reports from using Apache ant in Jmeter.
Please attach screenshots
There won't be too much screenshots, however I believe the answer will still be helpful
Install Apache Ant. Make sure that /bin folder of Ant installation is in your PATH
Go to "extras" folder of your JMeter installation in command propmt.
Type ant
If everything goes well you should see "BUILD SUCCESSFUL" message
Ant will generate 2 artifacts:
Test.jtl - XML file with results
Test.html - HTML wile with results which can be viewed in browser
If steps 1-5 are successful you can now replace /extras/Test.jmx with your own JMeter test, delete Test.jtl file and execute step 3 for your test script.
See following references:
/extras/build.xml Ant build file
JMeter Ant Task manual
Five Ways To Launch a JMeter Test without Using the JMeter GUI guide which includes launching JMeter via Ant.
JMeter produces the result in XML format. You need an XSLT file to convert this to a nice HTML.
This site has the detailed steps on running JMeter tests with ANT + creating HTML reports + Creating charts.
http://www.testautomationguru.com/jmeter-continuous-performance-testing-part1/
I have a Jenkins build which build all my java/angularJS project. It launch testNG tests for the java part and karma tests for the javascript part. So I can generate one testNG report (for java) and one junit report (for karma test) in my Jenkins build. This is working very well.
Until now, I used cobertura to report the coverage of my java tests. But now I would like to add also a coverage report for my karma tests (generated by Istanbul with cobertura type). The problem is that, in Jenkins, I'm allowed to generate only one coverage report in a build (I can't add more that one 'publish cobertura coverage report' post build action). So how can I have these two coverage reports in a single Jenkins build?
There's a nice plugin called HTML Publisher Plugin. You can generate HTML coverage reports and publish as much reports as you want under different titles in one Jenkins project.
For example I generate html reports using karma+istanbul and then publish them to Jenkins.
On JUnit xml report files. You should import JUnit once enumerating all files probably from different directories but you can differentiate them with proper package names inside files.
If I'm right, you can't use, as a post build action, the same plug-in twice( note that I'm not really sure). I faced this problem when I worked as Jenkins plug-in developer for a company and the solution was to use a plug-in that make the same thing.
For example: for JUnit reports there is an official JUnit plugin and also XUnit. For my problem it was simple.
So, maybe you can find a plug-in that do the same thing as Cobertura or you can change the output format of the java coverage or karma coverage. For example, for java you can use EclEmma or Jacoco...
Im working on getting our CI (Jenkins) to use and run our qunit test, we have qunit-reporter, qunit.compposite and phantomjs to execute the whole. Im not ant expert so im using windows batch command as a prestep with the following command
phantomjs src\test\webapp\js\runner.js src\test\webapp\jquery.all.test.html > test-report.xml
Now this runs and generates the junit xml file, with a few issues, firstly since I use pipe phantomjs performance information is also put into the file so that's my first issue
My second issue is that I have no idea in the world how I can get Jenkins to actually read the xml file instead of just considering it random stuff, similar to it interpreting when we have junit test run.
Just for reference the project is a maven project.
All advice is welcome :)
In Jenkins, configure your job, add a post build action, select publish JUnit test result report then add the path to your xml file in the requested field.
A couple years ago, a colleague of mine and I worked on getting PhantomJS to run QUnit tests and output JUnit XML that Jenkins can consume:
http://www.cameronjtinker.com/post/2013/09/24/QUnit-JSCoverage-and-Jenkins.aspx
I had forgotten to post this on my blog after we worked on this so I just posted it today when I saw your question. Much has changed since 2011 when this was originally written, but it should have most of the same concepts involved.