Performance Testing
Bard provides the ability to assert that the API responses are returned within a specified timeframe. This can be asserted at a test level or globally for an entire Scenario.

Individual API Call Assertion

The test below show an individual assertion for a specific end point.
1
[Fact]
2
public void The_slow_running_endpoint_should_return_within_two_seconds()
3
{
4
When
5
.Get("api/slow-running-endpoint");
6
7
Then
8
.Response
9
.Time
10
.LessThan(2000); // Time in milliseconds.
11
12
}
Copied!

Global Configuration

The scenario configuration below demonstrates how to set a global benchmark for all API calls so that they do not exceed 2000 milliseconds.
1
var scenario = ScenarioConfiguration
2
.Configure(options =>
3
{
4
options.MaxApiResponseTime = 2000;
5
// Other configuration goes here..
6
});
Copied!
Last modified 1yr ago