I'm trying to run a simple provider contract test for a pact uploaded to the pactflow broker by a consumer test which can run without problems on the same PC. When I run the provider test I see this log:
2023-03-03 09:52:35.575 INFO 22944 --- [ main] c.a.c.c.test.FaturaOdemeContractTest : Started FaturaOdemeContractTest in 8.261 seconds (JVM running for 15.164)
org.junit.runners.model.InitializationError
at au.com.dius.pact.provider.junit.PactRunner.checkIgnoreIoException(PactRunner.kt:130)
at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:99)
at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:152)
at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426)
at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:351)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:85)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
2023-03-03 09:53:18.082 INFO 22944 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2e8e8225: startup date [Fri Mar 03 09:52:28 EET 2023]; root of context hierarchy
2023-03-03 09:53:18.086 INFO 22944 --- [ Thread-2] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2023-03-03 09:53:18.088 INFO 22944 --- [ Thread-2] o.s.i.endpoint.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2023-03-03 09:53:18.088 INFO 22944 --- [ Thread-2] o.s.i.channel.PublishSubscribeChannel : Channel 'application:0.errorChannel' has 0 subscriber(s).
2023-03-03 09:53:18.088 INFO 22944 --- [ Thread-2] o.s.i.endpoint.EventDrivenConsumer : stopped _org.springframework.integration.errorLogger
2023-03-03 09:53:18.089 INFO 22944 --- [ Thread-2] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
So I guess JUnitRunner cannot find any unit tests to run. But how can I see why it cannot? Is there a firewall or an authentication problem? I've seen the post here but it didn't help.
Here is the pom entry I use for provider:
<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>spring</artifactId>
<version>4.1.41</version>
<scope>test</scope>
<exclusions>
<!-- When I don't exclude this, I get guava not found.:
See: 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>
Here is the consumer POM which upload the contract OK to the broker:
<plugin>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>maven</artifactId>
<version>4.1.17</version>
<configuration>
<pactBrokerUrl>https://akbank.pactflow.io</pactBrokerUrl>
<pactBrokerToken>MyToken</pactBrokerToken>
</configuration>
</plugin>
Here is the PactUrl annotation I use on the provider junit test:
@PactUrl(
urls="https://akbank.pactflow.io/pacts/provider/fatura-service/consumer/Mobil Mudurluk Fatura Ekibi/latest",
auth = @Authentication(token = "MyToken"))
When I try to use @PactFolder("pacts") everything works ok. But in this case I have to use au.com.dius:pact-jvm-provider-spring_2.12:3.5.24 otherwise I get a method not found exception in gson.
The problem was proxy settings of the JUnit Run configuration of Eclipse. I had to specify proxy settings in the run configuration and got it solved.