danger-junit
A description of danger-junit.
Installation
$ gem install danger-junit
Usage
junit
Report, or inspect any JUnit XML formatted test suite report.
Testing frameworks have standardized on the JUnit XML format for reporting results, this means that projects using Rspec, Jasmine, Mocha, XCTest and more - can all use the same Danger error reporting. Perfect.
You can see some examples on this page from Circle CI about how you can add JUnit XML output for your testing projects.
Parse the XML file, and let the plugin do your reportingjunit.parse "/path/to/output.xml" junit.report
Let the plugin parse the XML file, and report yourselfjunit.parse "/path/to/output.xml" fail("Tests failed") unless junit.fails.empty?
Warn on a report about skipped testsjunit.parse "/path/to/output.xml" junit.show_skipped_tests = true junit.report
Only show specific parts of your resultsjunit.parse "/path/to/output.xml" junit.headers = [:name, :file] junit.report
Only show specific parts of your resultsjunit.parse "/path/to/output.xml" all_test = junit.tests.map(&:attributes) slowest_test = sort_by { |attributes| attributes[:time].to_f }.last "#{slowest_test[:time]} took #{slowest_test[:time]} seconds"
Attributes
tests - All the tests for introspection
passes - An array of XML elements that represent passed tests.
failures - An array of XML elements that represent failed tests.
errors - An array of XML elements that represent passed tests.
skipped - An array of XML elements that represent skipped tests.
show_skipped_tests - An attribute to make the plugin show a warning on skipped tests.
headers - An array of symbols that become the columns of your tests,
if nil, the default, it will be all of the attribues.
Methods
parse - Parses an XML file, which fills all the attributes
will raise for errors
report - Causes a build fail if there are test failures,
and outputs a markdown table of the results.
Development
- Clone this repo
- Run
bundle installto setup dependencies. - Run
bundle exec rake specto run the tests. - Use
bundle exec guardto automatically have tests run as you make changes. - Make your changes.