This Danger Plugin allows you to standardise the output for all of your testing runs. Most test runners include an ability to have a reporter that conforms to the JUnit XML standard. This plugin will understand that file and offer a way to introspect it, and to report on it.
$ gem install danger-junit
For Rspec, add the gem rspec_junit_formatter
to your project. Then use a .rspec
file to configure your tests to have multiple reporters. This file looks like:
...
--format documentation
--format RspecJunitFormatter --out junit-results.xml
...
Then you can pass the junit-results.xml
file to the plugin in your Dangerfile
.
In a Jasmine, or Jest testing project, you want to install the module jasmine-reporters
. Then as you are setting up your Jasmine runner, add the following:
var junitReporter = new jasmineReporters.JUnitXmlReporter({
savePath: 'junit-results.xml',
consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter);
Then you can pass the junit-results.xml
file to the plugin in your Dangerfile
.
Both xcpretty and XCTool include reporters for creating a JUnit XML file. As Fastlane's scan uses xcpretty, it also has support for the file.
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 message "#{slowest_test[:time]} took #{slowest_test[:time]} seconds"
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.
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.
- Clone this repo
- Run
bundle install
to setup dependencies. - Run
bundle exec rake spec
to run the tests. - Use
bundle exec guard
to automatically have tests run as you make changes. - Make your changes.
danger-junit's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.