- Introduction and Quick Overview
- Performance testing (Testing load and stress)
- One user-journey parallel load
- Combining single user-journeys(GET, POST, PUT etc)
- Multi scenario parallel load
- Load with gradually increasing or decreasing
- Maven library used
- Disbaling long-running HTML reports
Sample Performance Tests - Banking (Using JUnit and Zerocode test framework)
<dependency>
<groupId>org.jsmart</groupId>
<artifactId>zerocode-tdd-jupiter</artifactId>
<version>1.3.23</version> <!-- or higher -->
</dependency>
Then follow this WikiPage.
For JUnit4 parallel-run or load testing, follow the samples in the below sections.
<dependency>
<groupId>org.jsmart</groupId>
<artifactId>zerocode-tdd</artifactId>
<version>1.3.23</version>
</dependency>
See this GET
load test in the repo e.g.
@LoadWith("load_generation.properties")
@TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
@RunWith(ZeroCodeLoadRunner.class)
public class LoadGetTest {
}
Where, the load_generation.properties
has the below load e.g.
(100 requests in 100secs i.e. each request in 1 sec gap, looping twice, meaning 200 parallel requests)
number.of.threads=100
ramp.up.period.in.seconds=100
loop.count=2
It generates load for the below GET scenario:
@TargetEnv("screening_service_host.properties")
@RunWith(ZeroCodeUnitRunner.class)
public class GetScreeningServiceTest {
@Test
@JsonTestCase("load_tests/get/get_screening_details_by_custid.json")
public void testGetScreeningLocalAndGlobal() throws Exception {
}
}
Where the get_screening_details_by_custid.json
with payload and assertions/validations :
{
"scenarioName": "Screening API- Get Screening by customerId test",
"steps": [
{
"name": "get_screening_details",
"url": "/api/v1/screening/cust-ids/SINGAHV3033",
"method": "GET",
"request": {
},
"verify": {
"status": 200,
"body": {
"id" : "SINGAHV3033",
"localScreeningStatus" : "Green",
"globalScreeningStatus" : "Red"
}
}
}
]
}
See the suite test firing different loads with single scenario each
e.g.
sample test-class: org.jsmart.zerocode.samples.load.LoadTestSuite
@Suite.SuiteClasses({
LoadGetTest.class,
LoadPostTest.class,
LoadMultipleGetPostPutTest.class
})
@RunWith(Suite.class)
public class LoadTestSuite {
}
See the test-class org.jsmart.zerocode.samples.load.parallelmulti.LoadMultipleGetPostPutTest
/**
* What's new in ZeroCodeMultiLoadRunner.class ?
* ---------------------------------------------
* While running with "ZeroCodeMultiLoadRunner.class", each test mapping here is equivalent to one user,
* that means there are 3 concurrent users below invoking their respective user operations as:
* User-1) POST,GET
* User-2) PUT,GET
* User-3) GET
* User-N) so on
*
* Note :
* ------
* All 3 users are running in parallel which resembles the production like scenario where each user
* doing different jobs.
*
* You can keep feeding/adding as many tests by using @TestMapping(TestClassName.class, "testMethodName")
*
* Please make sure you set "number.of.threads" >= "number of test mappings(= 3 here)" giving chance for
* each scenario to get executed at least once.
*
*/
@LoadWith("load_generation.properties")
@TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
@TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
@TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
@RunWith(ZeroCodeMultiLoadRunner.class)
public class LoadMultipleGetPostPutTest {
}
You can(optionally) group the @TestMapping
s as below for better readability and pretty looking too.
@LoadWith("load_generation.properties")
@TestMappings({
@TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal"),
@TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations"),
@TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
})
@RunWith(ZeroCodeMultiLoadRunner.class)
public class LoadMultipleGroupAnnotationTest {
}
See the test-class org.jsmart.zerocode.samples.loadgradually.LoadGraduallyTestSuite
@Suite.SuiteClasses({
LoadGet1Per5SecTest.class, // <-- Less load (5 sec gap)
LoadGet1Per1SecTest.class, // <-- Bit more load (1 sec gap)
LoadGet5Per1SecTest.class // <-- Heavy load (0.2 sec gap)
})
@RunWith(Suite.class)
public class LoadGraduallyTestSuite {
}
- Download this project to run using your local IDE
- Latest release (includes Kafka testing):
<dependency>
<groupId>org.jsmart</groupId>
<artifactId>zerocode-tdd</artifactId>
<version>1.3.x</version>
</dependency>
- Visit here for the latest in Maven Central
- Or check here at zerocode maven-and-ci
- Visit here for the earlier releases Maven Central
The Interactive-Html-Report generation is enabled by default. For load testing this report may not be quite useful as we are mostly interested in load statistics which we can get from the CSV reports. Also the HTML interactive reports particularly takes bit longer to generate during load testing.
To disable this report generation please use the following flag in the host properties file annotated with @TargetEnv("app_host_sit.properties")
.
interactive.html.report.disabled=true