@DatabaseExpected not detected for rule java:S2699 resulting a false-positive

We use these versions :

  • sonar-maven-plugin:
  • SonarQube version:
  • Enterprise Edition Version 9.7 (build 61563)

We’ve got tests that trigger a java:S2699 blocker issue because there is no assertion in a test

    @DatabaseSetup(value = "insert.xml", type = CLEAN_INSERT)
    @DatabaseTearDown(value = "clean.xml", type = DELETE_ALL)
    @ExpectedDatabase(value = "expected.xml")
    void my_test() {
        // The code here to test my function that end up beeing validated by the ExpectedDatabase annotation

To discuss but I think that the ExpectedDatabase is enough to validate the behaviour of my test (as the .AndAssert() for mock API was once)

Is it possible to keep this rule but to change it so that it take this annotation in account ?
Thanks in advance

Hey there.

Just to make sure – is this annotation coming from GitHub - springtestdbunit/spring-test-dbunit: Integration between the Spring testing framework and DBUnit?

Thanks for your interest. Yes, it’s the annotation from DBUnit