Test API Performance

The ability to set a timeout for test execution and a module for load testing help you to measure your API performance.

Load Testing

BELLATRIX has a module which enables two types of load testing.

Load testing is a kind of performance testing which determines a system’s performance under real-life load conditions. This testing helps to determine how the application behaves when multiple users access it simultaneously. This testing usually identifies the maximum operating capacity of an application. BELLATRIX offers a module for making load tests. The first type of load test is time-based. 10 parallel processes run for 30 seconds, and the engine makes a pause of 1 sec between requests. As an anonymous method or existing method, you can specify the code to be executed in each process.

Time-Based Example

App.LoadTestService.ExecuteForTime(
    numberOfProcesses: 10,
    pauseBetweenStartSeconds: 1,
    secondsToBeExecuted: 30,
    testBody: () =>
{
    var response = _apiClientService.Get(request);

    response.AssertSuccessStatusCode();
    response.AssertExecutionTimeUnder(1);
});

Number-of-Times-Based Example

The second type of load test is number-of-times-based. Your code executes the specified number of times between the specified number of processes.

App.LoadTestService.ExecuteNumberOfTimes(5, 1, 5, () =>
{
    var response = _apiClientService.Get(request);

    response.AssertSuccessStatusCode();
    response.AssertExecutionTimeUnder(1);
});

Learn more

Measure Test Execution Times

Fail test if it exceeds a specified timeout

Sometimes it is useful to use your functional tests in order to measure performance or perhaps to just make sure that your app is not slow. To do that, Bellatrix libraries offer the ExecutionTimeUnder attribute whereby you specify a timeout. If the test is executed over it, the test fails.

[ExecutionTimeUnder(2)]
public class MeasuredResponseTimesTests : APITest

Another way to measure performance is to use the AssertExecutionTimeUnder method. If the request takes longer to execute, the test fails again.

response.AssertExecutionTimeUnder(2);

Learn more

Try Now Bellatrix

Build up to 100 tests using full product capabilities.

Download