Skip to content

Commit

Permalink
resolving old junit unit tests with the new format. Adding a skipped …
Browse files Browse the repository at this point in the history
…test node as a result

Signed-off-by: jkerry <john@kerryhouse.net>
  • Loading branch information
jkerry committed Feb 3, 2017
1 parent 1e21ace commit 7cabd42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 2 additions & 0 deletions lib/inspec/rspec_json_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ def build_result_xml(xml, control, result)
xml.testcase(name: result[:code_desc], class: test_class, time: result[:run_time]) do
if result[:status] == 'failed'
xml.failure(message: result[:message])
elsif result[:status] == 'skipped'
xml.skipped
end
end
end
Expand Down
15 changes: 3 additions & 12 deletions test/functional/inspec_exec_junit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@
end
end
describe 'the test suite' do
let(:suite) { doc.xpath("//testsuite").first}

it 'has a single properties element with no children' do
suite.xpath("//properties").length.must_equal 1
suite.xpath("//properties").children.length.must_equal 0
end
let(:suite) { doc.xpath("//testsuites/testsuite").first}

it 'must have 5 testcase children' do
suite.xpath("//testcase").length.must_equal 5
Expand All @@ -48,19 +43,15 @@
end

it 'has the failures attribute with 0 total tests' do
suite["failures"].must_equal "0"
end

it 'has the errors attribute with 0 total tests' do
suite["errors"].must_equal "0"
suite["failed"].must_equal "0"
end

it 'has 2 elements named "File /tmp should be directory"' do
suite.xpath("//testcase[@name='File /tmp should be directory']").length.must_equal 2
end

describe 'the testcase named "gordon_config Can\'t find file ..."' do
let(:gordon_yml_tests) { suite.xpath("//testcase[@classname='lib.inspec.runner']") }
let(:gordon_yml_tests) { suite.xpath("//testcase[@class='gordon-1.0' and @name='gordon_config']") }
let(:first_gordon_test) {gordon_yml_tests.first}

it 'should be unique' do
Expand Down

0 comments on commit 7cabd42

Please sign in to comment.