TCBE 002
Test Case Description | Verify JSON data while testing load |
Test Case ID | TCBE-002 |
Author/Designer | Otto Nordling |
Date of Creation | 05.07.2023 |
Class | Backend |
Test Description/Objective
JMeter can be used to load test the server. The objective of this test is to make JSON assertions while testing the load, which makes sure that specified paths exist and/or they have the correct values.
Links to requirements or other sources
- Requirement: PERF-REQ-0000
- Use case: Use Case
- Feature: N/A
Test Pre-state
Server is hosted locally in port 3001.
Test Steps
Step No. | Step Description | Expected Result |
---|---|---|
1 | Open JMeter | JMeter should open |
2 | Right click on 'Test Plan' and add a thread group (Add > Threads (Users) > Thread Group) | Thread group should appear under test plan |
3 | Change 'Number of Threads (users)' and 'Ramp-up period (seconds)' | The higher the users to seconds ratio, the bigger the load |
4 | Right click on the thread group and add a HTTP request (Add > Sampler > HTTP Request) | An HTTP Request should appear under the thread group |
5 | Change 'Server Name or IP' to 'localhost', 'Port Number' to '3001', Path to '/stations/20002?includeSensors=true', and 'Name' according to the station, like '20002' | This makes the JMeter GET station with the id '20002' |
6 | Right click on the HTTP request and add a JSON assertion (Add > Assertions > JSON Assertion) | A JSON assertion is created under the HTTP request |
7 | In the JSON assertion, write '$..longitude' | JMeter checks if longitude exists in the JSON file |
8 | Make another JSON assertion under '20002' | There are two JSON assertions under '20002' |
9 | Write '$..carriageway' in 'Assert JSON Path exists', check 'Additionally assert value' and type 'ONE_CARRIAGEWAY' in 'Expected Value' | JMeter checks if the station with the id '20002' has a value of 'ONE_CARRIAGEWAY' in 'carriageway' |
10 | Add a View results tree under Thread group (Add > Listener > View Results Tree) | A View results tree should appear under the Thread group |
11 | Hit 'Start' | '20002' should appear in 'View Results Tree' with a green check mark next to it |
To be taken into account during the test
-
Load testing can put a significant load on your server, so make sure you perform these tests in a controlled environment and avoid testing on production systems without proper planning.
-
Station 20002 was chosen for this test, but other stations could be tested as well.
-
When hosted locally, all stations and their IDs can be found at [http://localhost:3001/stations/]
-
When hosted locally, the keys and their values for any chosen station can be viewed at [http://localhost:3001/stations/{Insert-Station-ID-Here}?includeSensors=true]
Test Result (Pass/Fail Criteria)
- PASS condition: The 'View Results Tree' shows the HTTP request with green check marks
- FAIL condition: The 'View Results Tree' shows red Xs next to the HTTP requests. This tree will have a drop menu showing JSON Assertion if there's an error. Clicking on the JSON Assertion will show the assertion result telling the expected and fetched value.