Skip to content

Hooking into incoming Test Data

Tom Longhurst edited this page Nov 25, 2021 · 1 revision

You can hook into incoming test data by creating a class that implements the interface IBDTestDataReceiver

I created one to check incoming data for test failures, and if there were any, and my branch being tested was the main branch, then fire a notification to our team's Microsoft Teams channel.

public class TeamsNotificationWebHookService : IBDTestDataReceiver
    {
       public async Task OnReceiveTestDataAsync(BDTestOutputModel bdTestOutputModel)
        {
            ...
            // Some logic to do with the data - E.g. 
            if(bdTestOutputModel.Scenarios.Where(scenario => scenario.Status == Status.Failed))
            {
                // Send teams notification
            }
            ...
        } 
    }

And in startup, make sure to add:

app.UseBDTestReportServer(options =>
{
    ...
    options.DataReceiver = new TeamsNotificationWebHookService();
    ...
});
Clone this wiki locally