Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jenkins_junit_builder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jenkins_junit_builder

  • 0.0.6
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Gem Version

Jenkins CI compatible Junit XML report builder

When you have your own home brewed testing framework but still want to use Jenkins CI with it's standard JUnit plugin, you may find yourself searching for a valid and recent documentation on how to create such XML documents. It's hard. Harder for newbies who want to learn how to set up/use Jenkins and make it useful to their projects.

The XSD schema that serves as a base of the XMLs generated can be found here.

I have put together a blog entry on describing how the XML is interpreted and presented by Jenkins.

Installation

Add this line to your application's Gemfile:

gem 'jenkins_junit_builder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jenkins_junit_builder

Since it uses Nokogiri to build report XMLs, please refer to Nokogiri's documentation for more installation instructions if you run into build errors.

Usage

Please note that understanding how to read an XSD schema (which is not that hard) will really help navigating and understanding what properties are available and how to structure them. Again, Jenkins looks like to work by this XSD schema.

Since we are building our own testing system, I did something that is not soooo magical as a DSL with raibows and Unikitties.


Require the lib:

require 'jenkins_junit_builder'

Let's report a pass:

t_passed           = JenkinsJunitBuilder::Case.new
t_passed.name      = 'My first test case'
t_passed.time      = 65
t_passed.classname = 'FirstTestSuite'
t_passed.result    = JenkinsJunitBuilder::Case::RESULT_PASSED

Then a failure:

t_failed                    = JenkinsJunitBuilder::Case.new
t_failed.name               = 'My failing functionality'
t_failed.classname          = 'FirstTestSuite'
t_failed.result             = JenkinsJunitBuilder::Case::RESULT_FAILURE
t_failed.message            = 'timeout reached'
t_failed.system_out.message = 'some thing went wrong'
t_failed.system_err.message = 'give me a stacktrace or something'

Add those to the suite:

t_suite         = JenkinsJunitBuilder::Suite.new
t_suite.name    = 'Testing some cases'
t_suite.package = 'Mytest'
t_suite.add_case t_passed
t_suite.add_case t_failed

And bake them:

xml_report = t_suite.build_report

Into this:

<testsuites>
  <testsuite name="Testing some cases" package="Mytest">
    <testcase name="My first test case" time="65" classname="Mytest.FirstTestSuite"/>
    <testcase name="My failing functionality" classname="Mytest.FirstTestSuite">
      <failure message="timeout reached"/>
      <system-out>some thing went wrong</system-out>
      <system-err>give me a stacktrace or something</system-err>
    </testcase>
  </testsuite>
</testsuites>

Please refer to the tests and code for more guidance for the time being.


##Changelog 0.0.6

  • Simplified require

0.0.5

  • Still learning rubygem dependencies the hard way

0.0.4

  • Added support to package attribute

0.0.3

  • Changed require mechanism to be compatible with JRuby 1.7 (and MRI 1.9.3)

0.0.2

  • Learned that rubygems have their runtime dependency list in the gemspec (A.K.A first working version)

Contributing

  1. Fork it ( https://github.com/vadviktor/jenkins_junit_builder/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Written with StackEdit.

FAQs

Package last updated on 07 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc