Ensure that if TestNG tests all fail in setup then the test task fails
index 7ebd1fd..b78f0f9 100644
@@ -8,6 +8,9 @@
           incorrect types for the default values for the `exploded` optional property. This is unlikely to have
           caused problems during normal usage but could lead to unexpected behaviour when the innards of these
           methods were monkey patched and expected the "correct" type for these properties.
+* Fixed:  If all of the TestNG tests failed during the test setup then these tests would not be written to the
+          list of failed tests which would mean that buildr would not mark the containing projects test task as
+          failing when it runs. This has been patched to report any errors and fail the test task as expected.
 1.5.8 (2019-07-14)
 * Fixed:  Changed references to `https://repo1.maven.org/maven2` to use https where possible.
diff --git a/lib/buildr/java/tests.rb b/lib/buildr/java/tests.rb
index 3cb1156..23bf719 100644
--- a/lib/buildr/java/tests.rb
+++ b/lib/buildr/java/tests.rb
@@ -330,17 +330,19 @@
         tmp.write cmd_args.join("\n")
         Java::Commands.java ['org.testng.TestNG', "@#{tmp.path}"], cmd_options
-        return tests
-      rescue
-        # testng-failed.xml contains the list of failed tests *only*
-        report = File.read(File.join(task.report_to.to_s, 'testng-failed.xml'))
-        failed = report.scan(/<class name="(.*?)">/im).flatten
-        error "TestNG regexp returned unexpected failed tests #{failed.inspect}" unless (failed - tests).empty?
-        # return the list of passed tests
-        return tests - failed
         tmp.close unless tmp.nil?
+      # testng-failed.xml contains the list of failed tests *only*
+      failed_tests = File.join(task.report_to.to_s, 'testng-failed.xml')
+      if File.exist?(failed_tests)
+        report = File.read(failed_tests)
+        failed = report.scan(/<class name="(.*?)">/im).flatten
+        # return the list of passed tests
+        return tests - failed
+      else
+        return tests
+      end