简体   繁体   English

使用 Zerocode 运行 Junit 测试套件

[英]Running a Junit Test Suite with Zerocode

I am trying to run a load test with Junit(4) using Zerocode.我正在尝试使用 Zerocode 使用 Junit(4) 运行负载测试。 I was able to run existing Junit test classes by following these tutorials按照这些教程,我能够运行现有的 Junit 测试类

I have a Junit test suite working properly and I would like to know how to use zerocode to start this test suite so it will run all the tests in all test classes for a load test.我有一个 Junit 测试套件工作正常,我想知道如何使用 zerocode 来启动这个测试套件,以便它将运行所有测试类中的所有测试以进行负载测试。 The examples above are describing how to run a selected test method or few only.上面的示例仅描述了如何运行选定的测试方法或少数几个。

I think you can not do this with Zerocode.我认为你不能用 Zerocode 做到这一点。

If you want to reuse your JUnit test you need to create a LoadScenario test class.如果您想重用您的 JUnit 测试,您需要创建一个 LoadScenario 测试 class。 In this class, you need to tell which test you are going to use and which method it should run.在这个 class 中,您需要说明您将使用哪个测试以及应该运行哪种方法。

For example例如

@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 {

}

Take a look a this repo hosted on github: https://github.com/authorjapps/performance-tests .看看托管在 github 上的这个 repo: https://github.com/authorjapps/performance-tests It is a showcase project for ZeroCode framework (load testing part of the framework).它是 ZeroCode 框架(框架的负载测试部分)的展示项目。 It contains load test samples created with the help of Zerocode framework.它包含在 Zerocode 框架的帮助下创建的负载测试示例。

You do not need Zerocode to achieve this.你不需要 Zerocode 来实现这一点。 You can simply use Maven SureFire plugin for the parallel running of your Suite class(which has reference to other tests classes).您可以简单地使用Maven SureFire插件来并行运行您的套件类(它引用了其他测试类)。

           <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>

Note: In this case you need to make sure all your test-methods/classes are actually/potentially can be run parallely.注意:在这种情况下,您需要确保所有测试方法/类实际上/潜在地可以并行运行。 Which means- In terms of the data you need to make sure you have designed them correctly so they are independent or not intended to overlap or block each other.这意味着-就数据而言,您需要确保已正确设计它们,以便它们独立或不打算相互重叠或阻塞。

This also holds good for the below situation, but here you are cherry-picking the tests yourself and you make sure they can be fed into a parallel runner.这也适用于以下情况,但在这里您自己挑选测试,并确保它们可以输入并行运行器。

1) But if you use @RunWith(ZeroCodeUnitRunner.class) on your individual test classes(not the Suite class), then you get a nice CSV report at the 'target' folder. 1) 但是,如果您在您的个人测试类(而不是 Suite 类)上使用@RunWith(ZeroCodeUnitRunner.class) ,那么您会在“目标”文件夹中获得一份不错的 CSV 报告。

Then you can use this report to generate various throughput graphs/statistics etc for your project or business audience.然后,您可以使用此报告为您的项目或业务受众生成各种吞吐量graphs/statistics等。 See the section Extract useful information from the data in this blog .请参阅从本博客Extract useful information from the data部分。

2) If you need to control your parallel runs, eg you want to fire 50 users in 60secs or 100 users in 60 secs or 1000 users in 300 secs etc, then you need Zerocode runners which helps you to easily achieve this. 2) 如果您需要控制并行运行,例如您想在 60 秒内触发50 users in 60secs100 users in 60 secs1000 users in 300 secs等,那么您需要 Zerocode 运行器来帮助您轻松实现这一目标。

@RunWith(ZeroCodeLoadRunner.class)
-or-
@RunWith(ZeroCodeMultiLoadRunner.class)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM