S2699 Support custom annotations as assertions

Could we please get a new parameter allowing to define customAssertionAnnotations?

Hi @Vincent_Privat ,

Before asking for this solution, what is the usecase/problem you are encountering ?

Hi Nicolas,
We are facing this issue in some of our tests because we defined our own annotation-based assertion mechanism to test our persistence classes, as follows:

void testUpdate() {
    // Do something that is not checked directly by a JUnit assert

So in this case we would like to tell SonarQube that @DatabaseAssert is an assertion.


This parameter should be available since SonarJava 5.11 (see ticket). Yet I’m not sure it will work with annotations.

@Lena you’re mentioning the custom methods, but I’m asking for a new feature allowing to define custom annotations. The plugin doesn’t allow to do that.

@Nicolas_Peru do you need more information? Right now I must disable this rule because we have a lot of unit tests based on an annotation-based assertion framework.