From 3ee2808e08ff49f48fcf6501d827b9baba4c8b70 Mon Sep 17 00:00:00 2001 From: jkerry Date: Mon, 21 Nov 2016 08:04:49 -0500 Subject: [PATCH] Adding the initial top-level functional tests for inspec result junit xml Signed-off-by: jkerry --- test/functional/inspec_exec_junit_test.rb | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/functional/inspec_exec_junit_test.rb diff --git a/test/functional/inspec_exec_junit_test.rb b/test/functional/inspec_exec_junit_test.rb new file mode 100644 index 000000000..99f8ce1a9 --- /dev/null +++ b/test/functional/inspec_exec_junit_test.rb @@ -0,0 +1,75 @@ +# encoding: utf-8 +# author: John Kerry + +require 'functional/helper' +require 'nokogiri' + +# +# +# +# +# +# + +describe 'inspec exec with junit formatter' do + include FunctionalHelper + + it 'can execute a simple file with the junit formatter' do + out = inspec('exec ' + example_control + ' --format junit --no-create-lockfile') + out.stderr.must_equal '' + out.exit_status.must_equal 0 + doc = Nokogiri::XML(out.stdout) + doc.errors.length.must_equal 0 + end + + it 'can execute the profile with the junit formatter' do + out = inspec('exec ' + example_profile + ' --format junit --no-create-lockfile') + out.stderr.must_equal '' + out.exit_status.must_equal 0 + puts out.stdout + doc = Nokogiri::XML(out.stdout) + doc.errors.length.must_equal 0 + end + +# +# +# +# +# +# +# +# +# +# +# +# + + describe 'execute a profile with junit formatting' do + let(:doc) { Nokogiri::XML(inspec('exec ' + example_profile + ' --format junit --no-create-lockfile').stdout) } + + describe 'the document' do + it 'has only one testsuite' do + doc.xpath("//testsuite").length.must_equal 1 + 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 + + it 'has the tests attribute with 5 total tests' do + suite["tests"].must_equal "5" + 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" + end + end +end