If you would like Mockito to append some additional warning messages to the console, which would help you when your test fails, then this recipe is perfect for you. It's very much related to the previous one so, in order to understand the background, please refer to the introductory part of the previous recipe.
If you want to have more information presented in your error message, you have to perform the following steps:
@RunWith(ConsoleSpammingMockitoJUnitRunner.class)
.What happens then is that additional exception messages gets printed on the console after the exception that is thrown:
This stubbing was never used -> at ....MeanTaxFactorCalculatorTest.should_calculate_mean_tax_factor(MeanTaxFactorCalculatorTest.java:25)
When the test is run, ConsoleSpammingMockitoJUnitRunner
appends a listener that finds all the stubs through WarningsCollector
, including the unused stubs for given mocks. When all of the warnings get collected, the ConsoleMockitoLogger
class prints them to the console after the test has failed.
18.116.65.130