danger-junit_results 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +119 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +20 -0
- data/Rakefile +16 -0
- data/danger-junit_results.gemspec +47 -0
- data/lib/danger_junit_results.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/junit_results/gem_version.rb +3 -0
- data/lib/junit_results/plugin.rb +89 -0
- data/spec/fixtures/junit-report-failures.xml +19 -0
- data/spec/fixtures/junit-report.xml +18 -0
- data/spec/junit_results_spec.rb +78 -0
- data/spec/spec_helper.rb +59 -0
- metadata +207 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 825751e9b733164244f54ad2eba1b3d53e890805
|
4
|
+
data.tar.gz: 099a390760fa7a7a4184bde05e2cbe32fe034bc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10087f2f807923f715e6a2f3d010334e1d4f9e524a69892e4d78c4ce504edcd3f2e797b3072956b2c94605cb71c116e7a61ca38aa6377e9c14e6208cd0b83f0f
|
7
|
+
data.tar.gz: a01e577fa031657e0ddaf5997fa4edbaa56e815b0c148623e72b73fc0e2a804f5e205ea8f85ff8229aa7764e289d3b1372f2df30a367e69016ef63272c530029
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-junit_results (0.0.1)
|
5
|
+
danger (~> 2.0)
|
6
|
+
nokogiri
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.4.0)
|
12
|
+
claide (1.0.0)
|
13
|
+
claide-plugins (0.9.1)
|
14
|
+
cork
|
15
|
+
nap
|
16
|
+
open4 (~> 1.3)
|
17
|
+
coderay (1.1.1)
|
18
|
+
colored (1.2)
|
19
|
+
cork (0.1.0)
|
20
|
+
colored (~> 1.2)
|
21
|
+
danger (2.1.1)
|
22
|
+
claide (~> 1.0)
|
23
|
+
claide-plugins (> 0.9.0)
|
24
|
+
colored (~> 1.2)
|
25
|
+
cork (~> 0.1)
|
26
|
+
faraday (~> 0)
|
27
|
+
faraday-http-cache (~> 1.0)
|
28
|
+
git (~> 1)
|
29
|
+
kramdown (~> 1.5)
|
30
|
+
octokit (~> 4.2)
|
31
|
+
terminal-table (~> 1)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
faraday (0.9.2)
|
34
|
+
multipart-post (>= 1.2, < 3)
|
35
|
+
faraday-http-cache (1.3.0)
|
36
|
+
faraday (~> 0.8)
|
37
|
+
ffi (1.9.14)
|
38
|
+
formatador (0.2.5)
|
39
|
+
git (1.3.0)
|
40
|
+
guard (2.14.0)
|
41
|
+
formatador (>= 0.2.4)
|
42
|
+
listen (>= 2.7, < 4.0)
|
43
|
+
lumberjack (~> 1.0)
|
44
|
+
nenv (~> 0.1)
|
45
|
+
notiffany (~> 0.0)
|
46
|
+
pry (>= 0.9.12)
|
47
|
+
shellany (~> 0.0)
|
48
|
+
thor (>= 0.18.1)
|
49
|
+
guard-compat (1.2.1)
|
50
|
+
guard-rspec (4.7.3)
|
51
|
+
guard (~> 2.1)
|
52
|
+
guard-compat (~> 1.1)
|
53
|
+
rspec (>= 2.99.0, < 4.0)
|
54
|
+
kramdown (1.11.1)
|
55
|
+
listen (3.0.7)
|
56
|
+
rb-fsevent (>= 0.9.3)
|
57
|
+
rb-inotify (>= 0.9.7)
|
58
|
+
lumberjack (1.0.10)
|
59
|
+
method_source (0.8.2)
|
60
|
+
mini_portile2 (2.1.0)
|
61
|
+
multipart-post (2.0.0)
|
62
|
+
nap (1.1.0)
|
63
|
+
nenv (0.3.0)
|
64
|
+
nokogiri (1.6.8)
|
65
|
+
mini_portile2 (~> 2.1.0)
|
66
|
+
pkg-config (~> 1.1.7)
|
67
|
+
notiffany (0.1.1)
|
68
|
+
nenv (~> 0.1)
|
69
|
+
shellany (~> 0.0)
|
70
|
+
octokit (4.3.0)
|
71
|
+
sawyer (~> 0.7.0, >= 0.5.3)
|
72
|
+
open4 (1.3.4)
|
73
|
+
pkg-config (1.1.7)
|
74
|
+
pry (0.10.4)
|
75
|
+
coderay (~> 1.1.0)
|
76
|
+
method_source (~> 0.8.1)
|
77
|
+
slop (~> 3.4)
|
78
|
+
rake (10.5.0)
|
79
|
+
rb-fsevent (0.9.7)
|
80
|
+
rb-inotify (0.9.7)
|
81
|
+
ffi (>= 0.5.0)
|
82
|
+
rspec (3.5.0)
|
83
|
+
rspec-core (~> 3.5.0)
|
84
|
+
rspec-expectations (~> 3.5.0)
|
85
|
+
rspec-mocks (~> 3.5.0)
|
86
|
+
rspec-core (3.5.2)
|
87
|
+
rspec-support (~> 3.5.0)
|
88
|
+
rspec-expectations (3.5.0)
|
89
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
90
|
+
rspec-support (~> 3.5.0)
|
91
|
+
rspec-mocks (3.5.0)
|
92
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
93
|
+
rspec-support (~> 3.5.0)
|
94
|
+
rspec-support (3.5.0)
|
95
|
+
sawyer (0.7.0)
|
96
|
+
addressable (>= 2.3.5, < 2.5)
|
97
|
+
faraday (~> 0.8, < 0.10)
|
98
|
+
shellany (0.0.1)
|
99
|
+
slop (3.6.0)
|
100
|
+
terminal-table (1.6.0)
|
101
|
+
thor (0.19.1)
|
102
|
+
yard (0.9.5)
|
103
|
+
|
104
|
+
PLATFORMS
|
105
|
+
ruby
|
106
|
+
|
107
|
+
DEPENDENCIES
|
108
|
+
bundler (~> 1.3)
|
109
|
+
danger-junit_results!
|
110
|
+
guard (~> 2.14)
|
111
|
+
guard-rspec (~> 4.7)
|
112
|
+
listen (= 3.0.7)
|
113
|
+
pry
|
114
|
+
rake (~> 10.0)
|
115
|
+
rspec (~> 3.4)
|
116
|
+
yard (~> 0.8)
|
117
|
+
|
118
|
+
BUNDLED WITH
|
119
|
+
1.12.5
|
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A guardfile for making Danger Plugins
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# To run, use `bundle exec guard`.
|
5
|
+
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
7
|
+
require 'guard/rspec/dsl'
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Valerio Mazzeo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# danger-junit_results
|
2
|
+
|
3
|
+
Exposes test results summary with detailed failures, given a path to a JUnit report file.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install danger-junit_results
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
junit_results.parse("/tmp/junit-report.xml")
|
12
|
+
junit_results.parse
|
13
|
+
|
14
|
+
## Development
|
15
|
+
|
16
|
+
1. Clone this repo
|
17
|
+
2. Run `bundle install` to setup dependencies.
|
18
|
+
3. Run `bundle exec rake spec` to run the tests.
|
19
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
20
|
+
5. Make your changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:specs)
|
5
|
+
|
6
|
+
task default: :specs
|
7
|
+
|
8
|
+
task :spec do
|
9
|
+
Rake::Task['specs'].invoke
|
10
|
+
Rake::Task['spec_docs'].invoke
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
14
|
+
task :spec_docs do
|
15
|
+
sh 'bundle exec danger plugins lint'
|
16
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'junit_results/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-junit_results'
|
8
|
+
spec.version = JunitResults::VERSION
|
9
|
+
spec.authors = ['Valerio Mazzeo']
|
10
|
+
spec.email = ['valerio.mazzeo@gmail.com']
|
11
|
+
spec.description = %q{Exposes test results summary with detailed failures, given a path to a JUnit report file.}
|
12
|
+
spec.summary = %q{Exposes test results summary with detailed failures, given a path to a JUnit report file.}
|
13
|
+
spec.homepage = 'https://github.com/valeriomazzeo/danger-junit_results'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'danger', '~>2.0'
|
22
|
+
spec.add_runtime_dependency 'nokogiri'
|
23
|
+
|
24
|
+
# General ruby development
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
|
28
|
+
# Testing support
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
30
|
+
|
31
|
+
# Linting code and docs
|
32
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
33
|
+
|
34
|
+
# Makes testing easy via `bundle exec guard`
|
35
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
36
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
37
|
+
|
38
|
+
# If you want to work on older builds of ruby
|
39
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
40
|
+
|
41
|
+
# This gives you the chance to run a REPL inside your test
|
42
|
+
# via
|
43
|
+
# require 'pry'
|
44
|
+
# binding.pry
|
45
|
+
# This will stop test execution and let you inspect the results
|
46
|
+
spec.add_development_dependency 'pry'
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'junit_results/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'junit_results/plugin'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Danger
|
2
|
+
# Exposes test results summary with detailed failures,
|
3
|
+
# given a path to a JUnit report file.
|
4
|
+
#
|
5
|
+
# @example Ensure all the tests are executed correctly
|
6
|
+
#
|
7
|
+
# junit_results.parse("/tmp/junit-report.xml")
|
8
|
+
# junit.report
|
9
|
+
#
|
10
|
+
# @see valeriomazzeo/danger-junit_results
|
11
|
+
# @tags junit, tests
|
12
|
+
#
|
13
|
+
class DangerJunitResults < Plugin
|
14
|
+
|
15
|
+
def initialize(arg)
|
16
|
+
super
|
17
|
+
@skipped_count = 0
|
18
|
+
@executed_count = 0
|
19
|
+
@failed_count = 0
|
20
|
+
end
|
21
|
+
|
22
|
+
# Total number of tests.
|
23
|
+
#
|
24
|
+
# @return [total_count]
|
25
|
+
attr_reader :total_count
|
26
|
+
|
27
|
+
# Total number of tests skipped.
|
28
|
+
#
|
29
|
+
# @return [skipped_count]
|
30
|
+
attr_reader :skipped_count
|
31
|
+
|
32
|
+
# Total number of tests executed.
|
33
|
+
#
|
34
|
+
# @return [executed_count]
|
35
|
+
attr_reader :executed_count
|
36
|
+
|
37
|
+
# Total number of tests failed.
|
38
|
+
#
|
39
|
+
# @return [failed_count]
|
40
|
+
attr_reader :failed_count
|
41
|
+
|
42
|
+
# An array of XML elements of the failed tests.
|
43
|
+
#
|
44
|
+
# @return [Array<Nokogiri::XML::Element>]
|
45
|
+
attr_reader :failures
|
46
|
+
|
47
|
+
# Parses tests.
|
48
|
+
# @return [success]
|
49
|
+
#
|
50
|
+
def parse(file_path)
|
51
|
+
require 'nokogiri'
|
52
|
+
|
53
|
+
@doc = Nokogiri::XML(File.open(file_path))
|
54
|
+
|
55
|
+
@total_count = @doc.xpath('//testsuite').map { |x| x.attr('tests').to_i }.inject(0){ |sum, x| sum + x }
|
56
|
+
@skipped_count = @doc.xpath('//testsuite').map { |x| x.attr('skipped').to_i }.inject(0){ |sum, x| sum + x }
|
57
|
+
@executed_count = @total_count - @skipped_count
|
58
|
+
@failed_count = @doc.xpath('//testsuite').map { |x| x.attr('failures').to_i }.inject(0){ |sum, x| sum + x }
|
59
|
+
|
60
|
+
@failures = @doc.xpath('//failure')
|
61
|
+
|
62
|
+
return @failed_count <= 0
|
63
|
+
end
|
64
|
+
|
65
|
+
# Prints a detailed report of the tests failures.
|
66
|
+
# @return [success]
|
67
|
+
#
|
68
|
+
def report
|
69
|
+
tests_executed_string = @executed_count == 1 ? "test" : "tests"
|
70
|
+
tests_failed_string = @failed_count == 1 ? "failure" : "failures"
|
71
|
+
|
72
|
+
if @failed_count > 0
|
73
|
+
fail("Executed #{@executed_count}(#{@total_count}) #{tests_executed_string}, with **#{@failed_count}** #{tests_failed_string} 🚨")
|
74
|
+
@failures.each do |failure|
|
75
|
+
fail("`[#{failure.content.split("/").last}] [#{failure.parent['name']}] #{failure['message']}`")
|
76
|
+
end
|
77
|
+
else
|
78
|
+
message("Executed #{@executed_count}(#{@total_count}) #{tests_executed_string}, with #{@failed_count} #{tests_failed_string} 🎉")
|
79
|
+
end
|
80
|
+
|
81
|
+
return @failed_count <= 0
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.instance_name
|
85
|
+
to_s.gsub("Danger", "").danger_underscore.split("/").last
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites>
|
3
|
+
<testsuite name="JUnitXmlReporter" errors="0" tests="2" skipped="2" failures="0" time="0" timestamp="2013-05-24T10:23:58" />
|
4
|
+
<testsuite name="JUnitXmlReporter" errors="0" tests="0" failures="0" time="0" timestamp="2013-05-24T10:23:58" />
|
5
|
+
<testsuite name="JUnitXmlReporter.constructor" errors="0" skipped="1" tests="3" failures="1" time="0.006" timestamp="2013-05-24T10:23:58">
|
6
|
+
<properties>
|
7
|
+
<property name="java.vendor" value="Sun Microsystems Inc." />
|
8
|
+
<property name="compiler.debug" value="on" />
|
9
|
+
<property name="project.jdk.classpath" value="jdk.classpath.1.6" />
|
10
|
+
</properties>
|
11
|
+
<testcase classname="JUnitXmlReporter.constructor" name="should default path to an empty string" time="0.006">
|
12
|
+
<failure message="test failure">Assertion failed</failure>
|
13
|
+
</testcase>
|
14
|
+
<testcase classname="JUnitXmlReporter.constructor" name="should default consolidate to true" time="0">
|
15
|
+
<skipped />
|
16
|
+
</testcase>
|
17
|
+
<testcase classname="JUnitXmlReporter.constructor" name="should default useDotNotation to true" time="0" />
|
18
|
+
</testsuite>
|
19
|
+
</testsuites>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites>
|
3
|
+
<testsuite name="JUnitXmlReporter" errors="0" tests="2" skipped="2" failures="0" time="0" timestamp="2013-05-24T10:23:58" />
|
4
|
+
<testsuite name="JUnitXmlReporter" errors="0" tests="0" failures="0" time="0" timestamp="2013-05-24T10:23:58" />
|
5
|
+
<testsuite name="JUnitXmlReporter.constructor" errors="0" skipped="1" tests="3" failures="0" time="0.006" timestamp="2013-05-24T10:23:58">
|
6
|
+
<properties>
|
7
|
+
<property name="java.vendor" value="Sun Microsystems Inc." />
|
8
|
+
<property name="compiler.debug" value="on" />
|
9
|
+
<property name="project.jdk.classpath" value="jdk.classpath.1.6" />
|
10
|
+
</properties>
|
11
|
+
<testcase classname="JUnitXmlReporter.constructor" name="should default path to an empty string" time="0.006">
|
12
|
+
</testcase>
|
13
|
+
<testcase classname="JUnitXmlReporter.constructor" name="should default consolidate to true" time="0">
|
14
|
+
<skipped />
|
15
|
+
</testcase>
|
16
|
+
<testcase classname="JUnitXmlReporter.constructor" name="should default useDotNotation to true" time="0" />
|
17
|
+
</testsuite>
|
18
|
+
</testsuites>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerJunitResults do
|
5
|
+
it 'should be a plugin' do
|
6
|
+
expect(Danger::DangerJunitResults.new(nil)).to be_a Danger::Plugin
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'with Dangerfile' do
|
10
|
+
before do
|
11
|
+
@dangerfile = testing_dangerfile
|
12
|
+
@junit_results = @dangerfile.junit_results
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'without failures' do
|
16
|
+
|
17
|
+
before do
|
18
|
+
@junit_results.parse("./spec/fixtures/junit-report.xml")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has to parse tests" do
|
22
|
+
|
23
|
+
expect(@junit_results.total_count).to eq(5)
|
24
|
+
expect(@junit_results.skipped_count).to eq(3)
|
25
|
+
expect(@junit_results.executed_count).to eq(2)
|
26
|
+
expect(@junit_results.failed_count).to eq(0)
|
27
|
+
expect(@junit_results.failures).to be_empty
|
28
|
+
expect(@dangerfile.status_report[:messages]).to be_empty
|
29
|
+
expect(@dangerfile.status_report[:warnings]).to be_empty
|
30
|
+
expect(@dangerfile.status_report[:errors]).to be_empty
|
31
|
+
expect(@dangerfile.status_report[:markdowns]).to be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has to report successfully" do
|
35
|
+
expect(@junit_results.report).to be true
|
36
|
+
expect(@dangerfile.status_report[:messages].first).to eq("Executed 2(5) tests, with 0 failures 🎉")
|
37
|
+
expect(@dangerfile.status_report[:warnings]).to be_empty
|
38
|
+
expect(@dangerfile.status_report[:errors]).to be_empty
|
39
|
+
expect(@dangerfile.status_report[:markdowns]).to be_empty
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'with failures' do
|
45
|
+
|
46
|
+
before do
|
47
|
+
@junit_results.parse("./spec/fixtures/junit-report-failures.xml")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has to parse tests" do
|
51
|
+
|
52
|
+
expect(@junit_results.total_count).to eq(5)
|
53
|
+
expect(@junit_results.skipped_count).to eq(3)
|
54
|
+
expect(@junit_results.executed_count).to eq(2)
|
55
|
+
expect(@junit_results.failed_count).to eq(1)
|
56
|
+
expect(@junit_results.failures).not_to be_empty
|
57
|
+
expect(@dangerfile.status_report[:messages]).to be_empty
|
58
|
+
expect(@dangerfile.status_report[:warnings]).to be_empty
|
59
|
+
expect(@dangerfile.status_report[:errors]).to be_empty
|
60
|
+
expect(@dangerfile.status_report[:markdowns]).to be_empty
|
61
|
+
end
|
62
|
+
|
63
|
+
it "has to report successfully" do
|
64
|
+
expect(@junit_results.report).to be false
|
65
|
+
expect(@junit_results.failures).not_to be_empty
|
66
|
+
expect(@junit_results.failures.first.class).to eq(Nokogiri::XML::Element)
|
67
|
+
expect(@dangerfile.status_report[:messages]).to be_empty
|
68
|
+
expect(@dangerfile.status_report[:warnings]).to be_empty
|
69
|
+
expect(@dangerfile.status_report[:errors].first).to eq("Executed 2(5) tests, with **1** failure 🚨")
|
70
|
+
expect(@dangerfile.status_report[:errors][1]).to eq("`[Assertion failed] [should default path to an empty string] test failure`")
|
71
|
+
expect(@dangerfile.status_report[:markdowns]).to be_empty
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'danger'
|
11
|
+
|
12
|
+
# Use coloured output, it's the best.
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.filter_gems_from_backtrace "bundler"
|
15
|
+
config.color = true
|
16
|
+
config.tty = true
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'danger_plugin'
|
20
|
+
|
21
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
22
|
+
# If you are expanding these files, see if it's already been done ^.
|
23
|
+
|
24
|
+
# A silent version of the user interface,
|
25
|
+
# it comes with an extra function `.string` which will
|
26
|
+
# strip all ANSI colours from the string.
|
27
|
+
|
28
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
29
|
+
def testing_ui
|
30
|
+
@output = StringIO.new
|
31
|
+
def @output.winsize
|
32
|
+
[20, 9999]
|
33
|
+
end
|
34
|
+
|
35
|
+
cork = Cork::Board.new(out: @output)
|
36
|
+
def cork.string
|
37
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
38
|
+
end
|
39
|
+
cork
|
40
|
+
end
|
41
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
42
|
+
|
43
|
+
# Example environment (ENV) that would come from
|
44
|
+
# running a PR on TravisCI
|
45
|
+
def testing_env
|
46
|
+
{
|
47
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
48
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
49
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
50
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
51
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# A stubbed out Dangerfile for use in tests
|
56
|
+
def testing_dangerfile
|
57
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
58
|
+
Danger::Dangerfile.new(env, testing_ui)
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-junit_results
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Valerio Mazzeo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.7
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Exposes test results summary with detailed failures, given a path to
|
154
|
+
a JUnit report file.
|
155
|
+
email:
|
156
|
+
- valerio.mazzeo@gmail.com
|
157
|
+
executables: []
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- ".gitignore"
|
162
|
+
- ".travis.yml"
|
163
|
+
- Gemfile
|
164
|
+
- Gemfile.lock
|
165
|
+
- Guardfile
|
166
|
+
- LICENSE.txt
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- danger-junit_results.gemspec
|
170
|
+
- lib/danger_junit_results.rb
|
171
|
+
- lib/danger_plugin.rb
|
172
|
+
- lib/junit_results/gem_version.rb
|
173
|
+
- lib/junit_results/plugin.rb
|
174
|
+
- spec/fixtures/junit-report-failures.xml
|
175
|
+
- spec/fixtures/junit-report.xml
|
176
|
+
- spec/junit_results_spec.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
homepage: https://github.com/valeriomazzeo/danger-junit_results
|
179
|
+
licenses:
|
180
|
+
- MIT
|
181
|
+
metadata: {}
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 2.5.1
|
199
|
+
signing_key:
|
200
|
+
specification_version: 4
|
201
|
+
summary: Exposes test results summary with detailed failures, given a path to a JUnit
|
202
|
+
report file.
|
203
|
+
test_files:
|
204
|
+
- spec/fixtures/junit-report-failures.xml
|
205
|
+
- spec/fixtures/junit-report.xml
|
206
|
+
- spec/junit_results_spec.rb
|
207
|
+
- spec/spec_helper.rb
|