找不到契约文件可以验证

发布于 2025-02-13 04:57:16 字数 2507 浏览 2 评论 0原文

我面临着奇怪的问题测试问题。但是,当我使用本地PACT-BROKR时,相同的测试正在通过时,当我使用远程PACT-BROKR测试时,则会失败。

systemProperty 'pactbroker.url', 'https://pact-broker.internal-dev.com/' // Test is failing

systemProperty 'pactbroker.url', 'http://localhost:9292/' // Test is passing, I have setup locally and published to it

错误:

No Pact files were found to verify
Provider: Provider1
Source: Pact Broker https://pact-broker.internal-dev.com/
au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify
Provider: Provider1
Source: Pact Broker https://pact-broker.internal-dev.com/
    at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:49)
    at au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider.provideTestTemplateInvocationContexts(PactVerificationSpringProvider.kt:24)
    at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:102) and more

有什么想法吗?

注意:这仅在一项服务中发生。对于所有其他服务,相同的设置工作正常,即使在本地经纪人主机中也可以正常工作。我试图调试和测试即将为空。

//异常点tests.first是空的,不应该是。当我使用Provider2时,它不是空的。

override fun provideTestTemplateInvocationContexts(context: ExtensionContext): Stream<TestTemplateInvocationContext> {
    logger.trace { "provideTestTemplateInvocationContexts called" }
    val tests = resolvePactSources(context)
    return when {
      tests.first.isNotEmpty() -> tests.first.stream() as Stream<TestTemplateInvocationContext>
      AnnotationSupport.isAnnotated(context.requiredTestClass, IgnoreNoPactsToVerify::class.java) ->
        listOf(DummyTestTemplate).stream() as Stream<TestTemplateInvocationContext>
      else -> throw NoPactsFoundException("No Pact files were found to verify\n${tests.second}")
    }
  }

当我使用提供商provider2(这是针对其他服务)而不是provider1(我需要这个)时,看来PACT已解决,并且不匹配测试的失败,此在设置的情况下,验证一切都很好。我猜这是版本控制问题,但不确定为什么要通过本地传递。我试图在出版商方面重命名提供商,并将其与新名称一起使用,但仍然相同。

服务器上的契约:

I am facing weird issue for pact testing. When I use local pact-broker same test is passing however, when I use remote pact-broker test is failing.

systemProperty 'pactbroker.url', 'https://pact-broker.internal-dev.com/' // Test is failing

systemProperty 'pactbroker.url', 'http://localhost:9292/' // Test is passing, I have setup locally and published to it

Errors:

No Pact files were found to verify
Provider: Provider1
Source: Pact Broker https://pact-broker.internal-dev.com/
au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify
Provider: Provider1
Source: Pact Broker https://pact-broker.internal-dev.com/
    at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:49)
    at au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider.provideTestTemplateInvocationContexts(PactVerificationSpringProvider.kt:24)
    at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:102) and more

Any idea?

Note: This is happening to only one service. For all other services, same setup is working fine and even this is working fine in local broker host. I tried to debug and tests is coming empty.

enter image description here

// Exception point tests.first is empty which should not be. It is not empty when I use Provider2 which for different service.

override fun provideTestTemplateInvocationContexts(context: ExtensionContext): Stream<TestTemplateInvocationContext> {
    logger.trace { "provideTestTemplateInvocationContexts called" }
    val tests = resolvePactSources(context)
    return when {
      tests.first.isNotEmpty() -> tests.first.stream() as Stream<TestTemplateInvocationContext>
      AnnotationSupport.isAnnotated(context.requiredTestClass, IgnoreNoPactsToVerify::class.java) ->
        listOf(DummyTestTemplate).stream() as Stream<TestTemplateInvocationContext>
      else -> throw NoPactsFoundException("No Pact files were found to verify\n${tests.second}")
    }
  }

When I used the provider Provider2(this is for other service) instead of Provider1(I need this), looks like pact is getting resolved and failing for not matching tests, this verifies everything is good in case of setup. I guess somehow it is versioning issue but not sure why passing in local. I tried to rename the provider in publisher side and use it with new name, still same issue.

Pacts on server:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文