You are here


26 July, 2019 - 09:51
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at

For more complex testing, TestCase provides the void fail(String failResponse) method. Calling this method will immediately cause the test method to fail and the failResponse string will be displayed. Since this method does not know the actual or expected results, the failResponse string should contain more detailed information about what exactly failed and how it failed. In the next screen shot is an example of using fail(...) where the test code was written such that it would fail:

Using fail(...) in a test method

Figure 7.5 The ***fail(...)*** method immediately throws an error exception when it is executed.