Mingliang Liu created FLINK-38488:
-------------------------------------

             Summary: Use 'throws Exception' instead of try-catch-fail in tests 
in flink-tests
                 Key: FLINK-38488
                 URL: https://issues.apache.org/jira/browse/FLINK-38488
             Project: Flink
          Issue Type: Improvement
          Components: Tests
            Reporter: Mingliang Liu


Currently we have some tests using following patter:
{code:java}
try {
  doTestSomething();
} catch (Exception e) {
  e.printStackTrace();
  fail(e.getMessage());
}{code}
This can be replaced by just throwing Exceptions in test and let JUnit handles 
the failure along with exception stack trace. The existing code loses stack 
trace information in test reports, and we need to look around in the stdout to 
guess.

As we can see other tests in Flink uses the "throws Exception" model:

  - The framework provides better formatting and integration with IDEs and CI 
systems
  - Test runners can distinguish between assertion failures and unexpected 
exceptions
 - Test logic is more readable without exception handling noise



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to