FINRAOS / JTAF-XCore

XCore is a framework to define and execute automated tests. It enables automation code development in Java, test script development in XML via domain specific language, and execution & reporting via JUnit.
http://finraos.github.io/JTAF-XCore/
Apache License 2.0
10 stars 17 forks source link

Tests Throwing Anonymous Exceptions Pass #84

Open MADiep opened 8 years ago

MADiep commented 8 years ago

When a test encounters an "anonymous" Exception, JTAF stops that particular test's execution and marks it as passed. For example, this will cause JTAF to pass the test:

throw new RuntimeException() {};

This is caused in Interpreter#interpret(TestScript). Specifically, towards the end of the method these lines are executed:

if (failure != null && failure.getClass().getSimpleName().equalsIgnoreCase(test.getException())) {
  failure = null;
  this.testStatus = TestStatus.Passed;
}

Because the Exception is anonymous, the getSimpleName() method returns an empty String. In most cases, test.getException() will also be an empty String, causing the code to flip the status to passing.