java - Rest Api 负载测试 Zerocode tdd 给出错误消息

标签 java junit5 rest-assured zerocode

我正在自动化我的rest api,并寻找一个与我的junit5 一起使用的性能测试框架。我遇到了 Zerocode tdd,但它并没有帮助它给出错误,并且所有测试都失败了。我的测试方法是正确的,并且在被 junit jupiter 正常调用时可以工作。当我使用 ZerocodeLoadRunner 来做同样的事情时,它不起作用。

    import org.jsmart.zerocode.core.domain.LoadWith;
    import org.jsmart.zerocode.core.domain.TestMapping;
    import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;   
    import org.junit.runner.RunWith;

    @LoadWith("loadConfig.properties")

    @TestMapping(testClass = MyTest.class, testMethod = "myMethod")

    @RunWith(ZeroCodeLoadRunner.class)

    public class LoadTest  {

    }

我收到的错误消息如下。

    2019-09-09 12:35:57,191 [main] ERROR org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner - myPackage.LoadTest.myMethod Failed. See target/logs -or- junit granular failure report(csv) -or- fuzzy search and filter report(html) for details

为此使用的依赖项如下

    <dependency>
        <groupId>org.jsmart</groupId>
        <artifactId>zerocode-tdd-jupiter</artifactId>
        <version>1.3.8</version>
    </dependency>

我不想使用任何测试工具,所以我就用这个。

最佳答案

您所做的设置适用于 JUnit4(但不适用于 JUnit5,因为 JUnit5 不支持 Runners)。对于JUnit5,您需要使用以下零代码扩展。

@ExtendWith({ParallelLoadExtension.class})

这个JUnit5-Jupiter-Parallel-Load-Extension页面有精确的详细信息。请尝试以下方法:

例如

@LoadWith("load_generation.properties")
@ExtendWith({ParallelLoadExtension.class})
public class JUnit5LoadCommonLoadTest {

    @Test
    @DisplayName("testing parallel load for X, Y and Z scenarios")
    @TestMappings({
            @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
            @TestMapping(testClass = JUnit5Test.class, testMethod = "testY"),
            @TestMapping(testClass = JUnit5MoreTest.class, testMethod = "testZ")
    })
    public void testLoad_xyz() {
        // This space remains empty
    }
}

您可以访问此Github JUnit5 Load examples了解 JUnit5 Jupiter 负载测试以及如何通过 JUnit5 Suite 运行它们。

关于java - Rest Api 负载测试 Zerocode tdd 给出错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57849469/

相关文章:

java - Hamcrest 检查值是否为 null 或空数组

java - 在 Java 中使用 XAdES-EPES 对 XML 进行签名

java - 字体嵌入错误 PDFA/1a iText 5.5.6

java - Junit 5 测试,获取 java.lang.IllegalStateException : Test classes cannot include @Bean methods

java - 如何将 JUnit 注解码合成自定义注解?

gradle - 如何为 JUnit 5 测试创建 HTML 报告?

java - 如何在放心中通过字段值查找对象?

java - 如何在 Java 中验证 JSON 模式?

java - 从单元格中检索 JTable 的行号

java - 有没有办法比较不同格式的时间戳?