Azure Pipelines logger extension for the Visual Studio Test Platform
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/AzurePipelines.TestLogger
tests/AzurePipelines.TestLogger.Tests
.editorconfig
.gitignore
AzurePipelines.TestLogger.sln
Directory.Build.props
LICENSE
README.md
ReleaseNotes.md
azure-pipelines.yml
build.cake
build.cmd
build.ps1
daveaglick.ruleset
stylecop.json

README.md

Azure Pipelines logger extension for the Visual Studio Test Platform.

NuGet

GitHub

Donations

If you found this library useful, consider kicking me a few bucks. I promise to use it on something totally frivolous and unrelated.

Buy Me A Coffee


What Is It?

This logger extensions allows you to send test results from a dotnet test session directly to Azure Pipelines in real-time as the tests are executed. It also talks directly to the Azure DevOps REST API and as a result can better represent your tests using Azure Pipelines conventions over other post-processing methods such as logging to a TRX file and processing with the PublishTestResults Azure Pipelines task.

Usage

In order for the logger to authenticate against the Azure DevOps API you'll need to expose the access token via an environment variable in your Azure Pipelines .yml file:

    env:
      SYSTEM_ACCESSTOKEN: $(System.AccessToken)

Installing Into Your Project

> dotnet test --test-adapter-path:. --logger:AzurePipelines
  • Test results are automatically reported to the Azure Pipelines CI results

Using Cake

An alternative to installing the logger directly into your test project is installing it as a tool in Cake:

#tool "AzurePipelines.TestLogger&version=1.0.0"

Then you can specify the logger during test runs when running on your CI server (the following is example code, your Cake build script may look or behave a little differently):

Task("Test")
    .Description("Runs all tests.")
    .IsDependentOn("Build")
    .DoesForEach(GetFiles("./tests/*Tests/*.csproj"), project =>
    {
        DotNetCoreTestSettings testSettings = new DotNetCoreTestSettings()
        {
            NoBuild = true,
            NoRestore = true,
            Configuration = configuration
        };
        if (isRunningOnBuildServer)
        {
            testSettings.Filter = "TestCategory!=ExcludeFromBuildServer";
            testSettings.Logger = "AzurePipelines";
            testSettings.TestAdapterPath = GetDirectories($"./tools/AzurePipelines.TestLogger.*/contentFiles/any/any").First();
        }

        Information($"Running tests in {project}");
        DotNetCoreTest(MakeAbsolute(project).ToString(), testSettings);
    })
    .DeferOnError();

Limitations

Note that right now, the Azure Pipelines test summary will only show statistics for top-level tests. That's not ideal for a logger that nests results like this one, but the clarity of grouping tests under their fixture is more valuable than listing a correct total in the test summary in my opinion. Thankfully the pass/fail will still "bubble up" so even though the summary may show fewer tests than actually exist, it'll still correctly indicate if any tests are failing (which would then require a drill-down to figure out which ones are failing).

There's an open feature suggestion here for showing all nested tests in the summary.

Credit

This project is based on appveyor.testlogger and xunit.