Bug Reporting Azure DevOps

Learn to create automatically bugs in Azure DevOps on test failure.

What Is Automatic Bug Reporting?

The automatic bug reporting is a BELLATRIX feature that will create a bug automatically in various bug tracking software if some of your tests fail. The plugin will populate the description, attach a screenshot, video of the test. Moreover, it will generate human-readable steps to reproduce.

Bellatrix

Bellatrix

Configuration

First, you need to install the Bellatrix.BugReporting.AzureDevOps NuGet package to your tests project. Next, you need to enable the Azure DevOps bug reporting BELLATRIX extension in your TestInitialize file.

[TestClass]
public class TestsInitialize : WebTest
{
    [AssemblyInitialize]
    public static void AssemblyInitialize(TestContext testContext)
    {
        App.UseUnityContainer();
        App.UseMsTestSettings();
        App.UseBrowserBehavior();
        App.UseLogExecutionBehavior();
        App.UseControlLocalOverridesCleanBehavior();
        App.UseFFmpegVideoRecorder();
        App.UseFullPageScreenshotsOnFail();
        App.UseLogger();
        App.UseElementsBddLogging();
        App.UseHighlightElements();
        App.UseEnsureExtensionsBddLogging();
        App.UseLayoutAssertionExtensionsBddLogging();
        App.UseExceptionAnalysation();
        App.Initialize();
        
		App.UseBugReporting();
    	App.UseAssertExtensionsBugReporting();
    	App.UseEnsureExtensionsBugReporting();
    	App.UseLayoutAssertionExtensionsBugReporting();
    	App.UseAzureDevOpsBugReporting();

        App.AssemblyInitialize();
    }

    [AssemblyCleanup]
    public static void AssemblyCleanUp() => App.Dispose();
}

You need to add the following lines:

App.UseBugReporting();
App.UseAssertExtensionsBugReporting();
App.UseEnsureExtensionsBugReporting();
App.UseLayoutAssertionExtensionsBugReporting();
App.UseAzureDevOpsBugReporting();

They will turn on the feature and will assign listeners to common actions in the framework that will populate the auto-generated test case’s steps and expected results. Next, you need to add a new section in the testFrameworkSettings.json settings file.

"bugReportingSettings": {
  "isEnabled": "true",
  "url": "https://dev.azure.com/yourCompanyName",
  "token": "autheticationToken",
  "organizationName": "yourOrganizationname",
  "projectName": "yourProjectName",
  "defaultPriority": "2",
  "defaultSeverity": "2 - High"
},

You can read the the following article how to generate an authentication token.

NOTE: Be sure to enable this feature only in Release and for test projects that contain stable tests because otherwise, it can create a lot of bugs based on your flaky tests.