Another method provided by TestCase is void assertTrue(String failResponse, boolean result). This is a simplified version of assertEquals(...) used when the result can be expressed as a boolean true or false. Note that any test using assertTrue can also be written as assertEquals(failResponse, result, true). For instance we could write another test method to test the myMethod2() method of MyClass. The test class now has two test methods and JUnit will run both ot them when we click on "Test Current Document." Here, the second test method passes as shown in green below. The frst method still fails and its error messages are still shown. Clicking on the error message will highlight the line where the error occured. Correcting the code in myMethod1(...) would result in all the test methods being listed in green with no error messages.
- 1652 reads