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: 8.4.2.36762

Sample code:

@Provider("derp")
@Consumer("glory")
@PactBroker
@RunWith(RestPactRunner.class)
public class FooProviderPactTest {

    @TestTarget
    public final MockMvcTarget target = new MockMvcTarget();

    @Before
    public void before() {
        MockitoAnnotations.initMocks(this);
    }

    @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: https://jira.sonarsource.com/browse/SONARJAVA-3102

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.

Cheers,
Michael

Thanks!

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