🃏
Bard
  • Introduction
  • Getting Started
    • Installation
    • Writing Your First Test
    • Configuration
    • .NET Fiddles
  • Anatomy Of A Scenario
    • Given
      • StoryData
      • StoryBook
      • Chapter
      • Story
    • When
    • Then
      • HTTP Response
      • Headers
      • Bad Requests
      • Performance Testing
  • Advanced
    • Dependency Injection
  • Miscellaneous
    • Change Log
    • Migration Guide
  • gRPC
    • Installation
    • Configuration
    • Writing A Test
  • Tips & Tricks
    • FAQ
Powered by GitBook
On this page
  • Individual API Call Assertion
  • Global Configuration

Was this helpful?

Export as PDF
  1. Anatomy Of A Scenario
  2. Then

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.

[Fact]
public void The_slow_running_endpoint_should_return_within_two_seconds()
{
    When
        .Get("api/slow-running-endpoint");
   
    Then
        .Response
        .Time
        .LessThan(2000); // Time in milliseconds.
    
}

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.

var scenario = ScenarioConfiguration
    .Configure(options =>
    {
        options.MaxApiResponseTime = 2000;
        // Other configuration goes here..
    });
PreviousBad RequestsNextDependency Injection

Last updated 4 years ago

Was this helpful?