我试图使用Zerocode在Junit(4)上运行一个负载测试。通过以下教程,我能够运行现有的Junit测试类
我有一个Junit测试套件工作正常,我想知道如何使用零代码启动这个测试套件,这样它就可以在所有测试类中运行所有的测试来进行负载测试。上面的例子描述了如何运行所选的测试方法,或者只运行少数测试方法。
发布于 2019-11-06 06:30:20
我想你不能用Zerocode做这个。
如果您想重用您的JUnit测试,您需要创建一个LoadScenario测试类。在这个类中,您需要知道要使用哪个测试以及应该运行哪个方法。
例如
@LoadWith("load_generation.properties")
@TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
@TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
@TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
@RunWith(ZeroCodeMultiLoadRunner.class)
public class JunitParallelMultiScenarioTest {
}看看github:https://github.com/authorjapps/performance-tests上托管的这个回购程序。它是ZeroCode框架的一个展示项目(该框架的负载测试部分)。它包含在Zerocode框架帮助下创建的负载测试示例。
发布于 2019-11-11 15:36:36
您不需要Zerocode来实现这一点。您可以简单地使用Maven SureFire插件来并行运行Suite类(它引用了其他测试类)。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<includes>
<include>org.jsmart.samples.tests.AnyTestSuite</include>
</includes>
<parallel>classes</parallel>
<!--<parallel>methods</parallel>--> <!-- Or use methods -->
</configuration>
</plugin>注意:在本例中,需要确保您的所有测试方法/类实际上/潜在地可以并行运行。这意味着-在数据方面,您需要确保您已经正确地设计了它们,以便它们是独立的,或者不打算相互重叠或相互阻塞。
这也适用于下面的情况,但在这里,你是自己挑选测试,并确保它们可以被输入到一个平行跑步者。
但是,如果在单个测试类(而不是Suite类)上使用@RunWith(ZeroCodeUnitRunner.class),那么可以在“目标”文件夹中得到一个很好的CSV报告。
然后,您可以使用此报告为项目或业务受众生成各种吞吐量、graphs/statistics等。请参阅本博客中的博客一节。
2)如果您需要控制您的并行运行,例如您想要触发50 users in 60secs、100 users in 60 secs或1000 users in 300 secs等,那么您需要Zerocode运行程序来帮助您轻松实现这一目标。
@RunWith(ZeroCodeLoadRunner.class)
-or-
@RunWith(ZeroCodeMultiLoadRunner.class)https://stackoverflow.com/questions/58657690
复制相似问题