Pact 提供者测试得到 InitializationError 但消费者可以上传合约

问题描述 投票:0回答:0

我正在尝试为通过消费者测试上传到 pactflow 代理的 pact 运行一个简单的提供商合同测试,该测试可以在同一台 PC 上正常运行。当我运行提供者测试时,我看到这个日志:

    2023-02-20 11:24:00.869  INFO 27444 --- [           main] c.a.c.c.test.FaturaOdemeContractTest     : Started FaturaOdemeContractTest in 7.212 seconds (JVM running for 10.877)
org.junit.runners.model.InitializationError
    at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:93)
    at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:140)
    at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426)
    at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:351)
2023-02-20 11:24:43.963  INFO 27444 --- [       Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@43df23d3: startup date [Mon Feb 20 11:23:54 EET 2023]; root of context hierarchy
    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-02-20 11:24:43.964  INFO 27444 --- [       Thread-2] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2023-02-20 11:24:43.966  INFO 27444 --- [       Thread-2] o.s.i.endpoint.EventDrivenConsumer       : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2023-02-20 11:24:43.966  INFO 27444 --- [       Thread-2] o.s.i.channel.PublishSubscribeChannel    : Channel 'application:0.errorChannel' has 0 subscriber(s).
2023-02-20 11:24:43.966  INFO 27444 --- [       Thread-2] o.s.i.endpoint.EventDrivenConsumer       : stopped _org.springframework.integration.errorLogger
2023-02-20 11:24:43.967  INFO 27444 --- [       Thread-2] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'

所以我猜 JUnitRunner 找不到要运行的任何单元测试。但是我怎么知道为什么它不能呢?是否存在防火墙或身份验证问题?我看过这里的帖子但没有帮助。

这是将合约 OK 上传给经纪人的消费者 POM:

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

这是我在提供者 junit 测试中使用的 PactBroker 注释:

@PactBroker(host = "akbank.pactflow.io", port = "443", authentication= @PactBrokerAuth(token="MyToken"))

当我尝试使用@PactFolder("pacts") 时,一切正常。但在这种情况下,我必须使用 au.com.dius:pact-jvm-provider-spring_2.12:3.5.24 否则我会在 gson 中得到一个方法未找到的异常。

pact pact-broker
© www.soinside.com 2019 - 2024. All rights reserved.