0

我正在尝试使用Localstack在我的集成测试中模拟 AWS。作者指示我们将 Localstack 与我们的 Java 测试集成如下:

import cloud.localstack.LocalstackTestRunner;
import cloud.localstack.TestUtils;

@RunWith(LocalstackTestRunner.class)
public class MyCloudAppTest {

但是,我的黄瓜测试如下:

@RunWith(Cucumber.class)
@CucumberOptions(  monochrome = true,
        features = "src/test/resources/",
        glue = "com/mydomain/services" )
public class MyFeatureTest {
}

由于我不能有两个 RunWith 注释,任何人都可以建议一个替代方案来同时使用 Localstack 和 cucumber 进行测试?

谢谢您的帮助。

4

1 回答 1

0

我接受了@Grasshopper 的建议,并按以下方式工作:

@RunWith(LocalstackDockerTestRunner.class)
@LocalstackDockerProperties(services = {"dynamodb"})
public class MyFeatureTest {

    @Test
    public void test() throws IOException {
        String [] argv = new String[]{ "-g","com/mydomain/services","./src/test/resources/myFeature.feature"};
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        cucumber.api.cli.Main.run(argv, contextClassLoader);
    }

}
于 2019-04-30T15:49:17.513 回答