SonarQube Support for WebTestClient

In SonarQube, We have a rule, S2699 - Tests should include assertions. This is not supported for WebTestClient as assertion happens inside webtestclient."/api/v1/").exchange().expectStatus().isOk().expectBody().jsonPath("$.success").isEqualTo(true);

The above code is able to assert the values but sonar rule shows it as an error.

Can WebTestClient be added to the supported list of frameworks?

hello @kavi-n,

Rule S2699 has a parameter customAssertionMethods where you can configure the signature of assert methods for additional frameworks. This parameter was added few months ago, so you need to have reasonably recent version of Java analyzer installed (it is for sure available on latest 7.9 LTS).

1 Like

Thanks!! @saberduck. We will upgrade to a newer version and try customAssertionMethods.