@@ -518,3 +518,45 @@ else
518
518
# TODO: add link to wiki page (#530)
519
519
print_errors_summary 'robotframework-maven-plugin' , errors_count
520
520
end
521
+
522
+ # Handle `mvn verify`
523
+ #
524
+ # Example:
525
+ # <testng-results skipped="0" failed="1" total="114" passed="113">
526
+ # <test name="When user at index page" duration-ms="559" started-at="2017-03-05T19:34:06Z" finished-at="2017-03-05T19:34:06Z">
527
+ # <class name="ru.mystamps.web.tests.cases.WhenUserAtIndexPage">
528
+ # <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">
529
+ # <exception class="java.lang.AssertionError">
530
+ # <message>
531
+ # <![CDATA[should exists link to page for listing categories]]>
532
+ # </message>
533
+ # <full-stacktrace>
534
+ # <![CDATA[java.lang.AssertionError: should exists link to page for listing categories
535
+ # at ru.mystamps.web.tests.cases.WhenUserAtIndexPage.shouldExistsLinkForListingCategories(WhenUserAtIndexPage.java:78)
536
+ # at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
537
+ # ...
538
+ #
539
+ failsafe_report = 'target/failsafe-reports/testng-results.xml'
540
+ unless File . file? ( failsafe_report )
541
+ warn ( "Couldn't find #{ failsafe_report } . maven-failsafe-plugin result is unknown" )
542
+ else
543
+ errors_count = 0
544
+ doc = Nokogiri ::XML ( File . open ( failsafe_report ) )
545
+ results = doc . xpath ( '/testng-results' ) . first
546
+ failures = results [ 'failed' ] . to_i
547
+ if failures > 0
548
+ doc . xpath ( '//test-method[@status="FAIL"]' ) . each do |node |
549
+ errors_count += 1
550
+
551
+ clazz = node . parent [ 'name' ]
552
+ file = 'src/test/java/' + clazz . gsub ( /\. / , '/' ) + '.java'
553
+ file = github . html_link ( file )
554
+ testcase = clazz . split ( '.' ) [ -1 ] + '.' + node [ 'name' ]
555
+ msg = node . xpath ( './exception/message' ) . text . strip
556
+ # TODO: highlight line number
557
+ fail ( "maven-failsafe-plugin error in #{ file } :\n Test case `#{ testcase } ` fails with error:\n #{ msg } " )
558
+ end
559
+
560
+ print_errors_summary 'maven-failsafe-plugin' , errors_count , 'https://github.com/php-coder/mystamps/wiki/integration-tests'
561
+ end
562
+ end
0 commit comments