Detect assertions in a called method

For several of our tests we’re getting a “Add at least one assertion to this test case.”.
The assertions are there just not in the method annotated with @Test. It’s present a few method-calls down the line.

I’d like to request an improvement that enables detection of assertion that are placed in called methods, regardless of how many calls down the line the assertion is.

Our use-case: Tests that only differ in setup and share code that does the assertion.


This suggestion is very interesting and we share the need for it. Although, this is a very hard problem that we tried to tackle at best for now. Indeed following the call graph to determine if there is an assertion in subsequent calls can prove to be tricky and complex, especially if you start hitting something which is outside the current source file.

As such, while the suggestion is very reasonable in its stake, it is very hard to answer to it with a ticket or timeframe that will promise you that this will be fixed soon.

That’s great to hear!

As for the difficulty, wouldn’t it make sense to only consider the call-graph for calls to files in the test directory? That way you don’t have to follow a call if it leaves that directory. Should reduce the difficulty by quite a lot. At least for Java projects.

This is a (relevant) optimization of the solution to improve the rule. So we would have to first have that solution which is not really straightforward.