我正在自动化我的rest api,并寻找一个性能测试框架来与我的junit5一起使用。我遇到了零代码测试驱动开发,但它没有帮助,它给出了错误,所有的测试都失败了。我的测试方法是正确的,当它被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>我不想使用任何测试工具,因此我将使用此工具。
发布于 2019-09-24 07:21:49
您所做的设置适用于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运行它们。
发布于 2021-01-08 02:46:29
我第二个问题的答案是,你正在使用JUnit4风格的测试进行设置,并且需要为JUnit5进行设置-我最近几周已经测试过了,并且完全按照上面指定的方式工作。
需要注意的一点是,在属性文件中,我发现需要设置比线程高15- 20 %的秒数(即线程20/秒25)。如果您不这样做,那么我通常会在零代码测试中看到失败
https://stackoverflow.com/questions/57849469
复制相似问题