Cagin Uludamar
Cagin Uludamar

Reputation: 476

"Skipping publishing verification results" error in pact for JUnit 4

When I run JUnit tests, contract tests run as expected but the results are not published to the pact broker. What do I need to do here? Here is the message I see on the console:

Skipping publishing verification results for source UrlSource(url=https://akbank.pactflow.io/pacts/provider/fatura-service/consumer/Mobil Mudurluk Fatura Ekibi/latest, pact=null)

My JUnit run configuration in Eclipse is as follows: enter image description here

Here is my JUnit test:

@RunWith(SpringRestPactRunner.class)
@Provider("fatura-service")
@PactUrl(
        urls="https://akbank.pactflow.io/pacts/provider/fatura-service/consumer/Mobil Mudurluk Fatura Ekibi/latest", 
        auth = @Authentication(token = "MyToken"))
//causes InitializationError: @PactBroker(consumerVersionSelectors = @VersionSelector(consumer="Mobil Mudurluk Fatura Ekibi"))
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class FaturaOdemeContractTest {
    @TestTarget
    public final Target target = new SpringBootHttpTarget();

    @State("Odenecek fatura varken")
    public void faturaVarken() {
        System.out.println("fatura varken!");
    }
    
    @State("Odenecek fatura yokken")
    public void faturaYokken() {
        System.out.println("fatura yokken!");
        FaturaOdemeMockServis mockServis = (FaturaOdemeMockServis) ContractTestConfiguration.getFaturaOdemeRestServis();
        mockServis.setFaturaVar(false);
    }
}

Due to organizational restrictions, I have to use JUnit 4 and the following pact provider version:

        <dependency>
      <groupId>au.com.dius.pact.provider</groupId>
      <artifactId>spring</artifactId>
      <version>4.1.25</version>
      <scope>test</scope>
        <exclusions>
            <!-- Çağın & Oğuz Nursaç: Bunu koymayınca guava bulunamadı hatası alıyoruz:
            Bkz: https://stackoverflow.com/questions/74886116/one-of-the-2-eclipse-instances-on-my-pc-gives-failed-to-read-artifact-descripto
            -->
          <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Upvotes: 0

Views: 293

Answers (2)

Cagin Uludamar
Cagin Uludamar

Reputation: 476

I changed @PactUrl annotation to @PactBroker in the test class and now it works:

@RunWith(SpringRestPactRunner.class)
@Provider("fatura-service")
@PactBroker(
        url="https://akbank.pactflow.io", 
        authentication=@PactBrokerAuth(token="MyToken"))
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class FaturaOdemeContractTest {
    @TestTarget
    public final Target target = new SpringBootHttpTarget();

    @State("Odenecek fatura varken")
    public void faturaVarken() {
        System.out.println("fatura varken!");
    }
    
    @State("Odenecek fatura yokken")
    public void faturaYokken() {
        System.out.println("fatura yokken!");
        FaturaOdemeMockServis mockServis = (FaturaOdemeMockServis) ContractTestConfiguration.getFaturaOdemeRestServis();
        mockServis.setFaturaVar(false);
    }
}

I don't know the difference between PactUrl and PactBroker. Documentation tells to use PactBroker though.

Strange thing is yesterday I was getting 407 Proxy Auth required error with the same code. I guess I came across with a problem in our proxy. Lets see when we'll face another problem here.

Upvotes: 0

Artem Ptushkin
Artem Ptushkin

Reputation: 1299

It's a matter of enabling this in Maven configuration properties, they will be propagated to JVM, see an example

Upvotes: 1

Related Questions