Pact-jvm: Tests fail when pact broker have no pacts for the provider

Created on 2 Dec 2017  路  3Comments  路  Source: pact-foundation/pact-jvm

I am creating a demo to present to my customer, but when I try to run the "pact test" while my broker is empty the tests fail. I would not expect an applications tests to fail when there are no consumers of the API yet.

Error message:

java.lang.Exception: Did not find any pact files for provider pact-provider

Test code:

@RunWith(PactRunner.class)
@Provider("pact-provider")
@PactBroker(host="${pactbroker.hostname:localhost}", port = "8080")
public class ConsumerPactTest {

    @TestTarget
    public final Target target = new HttpTarget(8888);

    @BeforeClass
    public static void startSpring(){
        SpringApplication.run(ProviderDemoApplication.class);
    }

    @State({"default", "extra"})
    public void toDefaultState() {
        System.out.println("Now service in default state");
    }
}

Problem: Tests fail when broker is empty.
Expected behavior: When a broker contains no tests for the current provider the tests should pass because there are no consumers.

question

All 3 comments

There is an annotation you can use to drive that behaviour. Docs are here: https://github.com/DiUS/pact-jvm/blob/master/pact-jvm-provider-junit/README.md#setting-the-test-to-not-fail-when-no-pacts-are-found-version-353

@uglyog would it be possible to update that link? It's broken at the moment. Thanks

Ok I believe it's this one https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit#setting-the-test-to-not-fail-when-no-pacts-are-found

Was this page helpful?
0 / 5 - 0 ratings