0
votes

I am trying to run a load test with Junit(4) using Zerocode. I was able to run existing Junit test classes by following these tutorials

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. The examples above are describing how to run a selected test method or few only.

2

2 Answers

2
votes

I think you can not do this with Zerocode.

If you want to reuse your JUnit test you need to create a LoadScenario test class. In this class, you need to tell which test you are going to use and which method it should run.

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. It is a showcase project for ZeroCode framework (load testing part of the framework). It contains load test samples created with the help of Zerocode framework.

0
votes

You do not need Zerocode to achieve this. You can simply use Maven SureFire plugin for the parallel running of your Suite class(which has reference to other tests classes).

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

Then you can use this report to generate various throughput graphs/statistics etc for your project or business audience. See the section Extract useful information from the data in this blog.

2) If you need to control your parallel runs, e.g. 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.

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