我在一个Spring-Boot项目中使用官方的Cloud Foundry Java Client (https://github.com/cloudfoundry/cf-java-client)。
如何为测试(而不是集成测试)模拟云铸造?
发布于 2018-08-21 21:00:36
您并不是真的为了测试而模拟Cloud Foundry Java客户机。既然你提到了“非集成测试”,所以我假设这是单元测试。您的被测服务应该实现接口,并且可以将实现委托给CF java客户端。您可以在单元测试中模拟服务方法。
...
//you mock this method using mocking frameworks such as mockito
public List<Organization> getOrganizations(){
//pseudo code. code implementation using the CF client.
//the cf client is not the service under test.
return cfclient.organizations().list...
}
...在集成测试的情况下,您可以使用WireMock模拟外部API调用。您可以模拟响应,以便客户端调用(或被测系统)将相应地处理/处理外部API响应。
https://stackoverflow.com/questions/51947316
复制相似问题