Pact test result in "TestCases should contain tests"

We’re using Pact to write and run our contract tests. Pact has its own annotation for their provider tests, e.g. @State instead of @Test to run the ‘states’ defined in the contract automatically against the service in test.

This results in many false positives “TestCases should contain tests” code smell with blocker severity.
Is there a work around or something that can be added to SQ to accommodate:

  • versions used:

Sample code:

public class FooProviderPactTest {

    public final MockMvcTarget target = new MockMvcTarget();

    public void before() {

    @State("Test State A")
    public void testA() {
       // Prepare service before interaction that require "default" state
       // ...
       System.out.println("Now service in default state");

    @State("Test State B")
    public void testB() {
       // Prepare service before interaction that require B state
       // ...
       System.out.println("Now service in B state");

This is something similar to:

Hello @rux,

Thanks for the feedback! We are indeed not covering this framework. I consequently created the following ticket to add its support: SONARJAVA-3531.

Its resolution should be included in the next version of the Java analyzer, to be included in SQ 8.5 (release expected very soon) and on SonarCloud probably at the end of next week.



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.