0

I doing an CDC provider test with pact and spring, I was able to generate the pact file, but when I use the pact json for provider testing , it came out below error :"No tests found matching Method runTest", here is my code:

@RunWith(SpringRestPactRunner.class)
@Provider("myProvider")
@PactFolder("target/pacts")
@WebMvcTest(MyController.class)
public class ProviderTest {
    @InjectMocks
    private MyController myController; # the controller I want to test
    @MockBean
    private MyService myService; # the dependency of controller

    @TestTarget
    public final Target target = new SpringBootHttpTarget();

    @State("my_state")
    public void runTest() {

    }
}

and the pact file is something like this:

... other parts
"providerStates": [
            {
                "name": "my_state"
            }
        ]
... other parts

it seems that my test cannot find the "my_state" ?

EDIT: here is my demo project , Please help take a look, Thanks! https://github.com/wuhuanxing/pact_demo

rellocs wood
  • 1,381
  • 4
  • 21
  • 36

1 Answers1

0

That pact is using version 3 of the pact specification. Make sure you're using the latest version of the pact jar to ensure it supports version 3. If you can create a reproducible example in a Github repository, you can ask for help on slack.pact.io.

Beth Skurrie
  • 1,333
  • 7
  • 8