按端点进行的提供商验证测试中的单独协议交互

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

我刚刚开始对我的系统采用Pact测试,该系统由一个提供者服务和一个作为用户的Angular前端组成。我成功设置了双方,因此,Angular应用程序生成了一个(单个)pact文件,该文件具有与我的提供程序服务的多个端点的许多交互。在提供程序中,我现在确实面临这样的问题,我的验证测试变得非常大且过于复杂,因为我必须在单个测试中使用所有数据模拟所有端点,例如:]]

@Provider("example-backend")
@PactFolder("pacts")
@SpringBootTest(...)
class ComprehensivePactTest {

    [...]

    @State("healthy")
    fun `healthy state`() {
        whenever(exampleService.dosomething(any())).thenReturn(exampleResponse)
        whenever(otherService.somethingElse()).thenReturn(otherResponse)
    }
}

是否有一种方法可以将契约与契约文件分开,从而使我的提供者可以进行多个小型验证测试?例如,我想对路径以“ / example”开头的所有请求进行验证测试,并对路径以“ / other”开头的第二项测试进行验证。

因此,我希望有一个较小的,集中的验证测试,例如:

@Provider("example-backend")
@PactFolder("pacts")
@SpringBootTest(...)
class ExampleEndpointPactTest {

    [... include some filter logic here ...]

    @State("healthy")
    fun `healthy state`() {
        whenever(exampleService.dosomething(any())).thenReturn(exampleResponse)
    }
}

@Provider("example-backend")
@PactFolder("pacts")
@SpringBootTest(...)
class OtherEndpointPactTest {

    [... include some filter logic here ...]

    @State("healthy")
    fun `healthy state`() {
        whenever(otherService.somethingElse()).thenReturn(otherResponse)
    }
}

还是我的思维有谬误?谢谢。

我刚刚开始对我的系统采用Pact测试,该系统由一个提供者服务和一个作为用户的Angular前端组成。我成功设置了两面,因此,Angular应用程序...

pact pact-jvm
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.