Skip to content

Commit cee5bff

Browse files
committed
Dangerfile: handle maven-failsafe-plugin report.
1 parent b733cb9 commit cee5bff

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Dangerfile

+42
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,45 @@ else
597597
# TODO: add link to wiki page (#530)
598598
print_errors_summary 'robotframework-maven-plugin', errors_count
599599
end
600+
601+
# Handle `mvn verify`
602+
#
603+
# Example:
604+
# <testng-results skipped="0" failed="1" total="114" passed="113">
605+
# <test name="When user at index page" duration-ms="559" started-at="2017-03-05T19:34:06Z" finished-at="2017-03-05T19:34:06Z">
606+
# <class name="ru.mystamps.web.tests.cases.WhenUserAtIndexPage">
607+
# <test-method status="FAIL" signature="shouldExistsLinkForListingCategories()[pri:0, instance:ru.mystamps.web.tests.cases.WhenUserAtIndexPage@2187fff7]" name="shouldExistsLinkForListingCategories" duration-ms="3" started-at="2017-03-05T20:34:06Z" finished-at="2017-03-05T20:34:06Z">
608+
# <exception class="java.lang.AssertionError">
609+
# <message>
610+
# <![CDATA[should exists link to page for listing categories]]>
611+
# </message>
612+
# <full-stacktrace>
613+
# <![CDATA[java.lang.AssertionError: should exists link to page for listing categories
614+
# at ru.mystamps.web.tests.cases.WhenUserAtIndexPage.shouldExistsLinkForListingCategories(WhenUserAtIndexPage.java:78)
615+
# at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
616+
# ...
617+
#
618+
failsafe_report = 'target/failsafe-reports/testng-results.xml'
619+
unless File.file?(failsafe_report)
620+
warn("Couldn't find #{failsafe_report}. maven-failsafe-plugin result is unknown")
621+
else
622+
errors_count = 0
623+
doc = Nokogiri::XML(File.open(failsafe_report))
624+
results = doc.xpath('/testng-results').first
625+
failures = results['failed'].to_i
626+
if failures > 0
627+
doc.xpath('//test-method[@status="FAIL"]').each do |node|
628+
errors_count += 1
629+
630+
clazz = node.parent['name']
631+
file = 'src/test/java/' + clazz.gsub(/\./, '/') + '.java'
632+
file = github.html_link(file)
633+
testcase = clazz.split('.')[-1] + '.' + node['name']
634+
msg = node.xpath('./exception/message').text.strip
635+
# TODO: highlight line number
636+
fail("maven-failsafe-plugin error in #{file}:\nTest case `#{testcase}` fails with error:\n#{msg}")
637+
end
638+
639+
print_errors_summary 'maven-failsafe-plugin', errors_count, 'https://github.com/php-coder/mystamps/wiki/integration-tests'
640+
end
641+
end

0 commit comments

Comments
 (0)