I have a build in VSTS, as follows:
You can see from the screen shot there's a test step to "Test and generate code coverage". It uses this command:
/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)\TestResults\Coverage\coverage
Which allows the code coverage report to be generated. I have added "Categories" to my xUnit tests with my defined Trait (such as integration or unit), to allow me to filter tests during build/release. Example would be:
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit.Abstractions;
using Xunit.Sdk;
/// <summary>
/// Decorates a test as a Unit Test, so that it runs in Continuous Integration builds.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class IsUnitAttribute : AICategoryAttribute
{
/// <summary>
/// Initializes a new instance of <see cref="IsUnitAttribute"/>
/// </summary>
public IsUnitAttribute() : base("Unit") { }
}
/// <summary>
/// Decorates a test as an Integration Test, so that it runs in Continuous Integration builds.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class IsIntegrationAttribute : AICategoryAttribute
{
/// <summary>
/// Initializes a new instance of <see cref="IsIntegrationAttribute"/>
/// </summary>
public IsIntegrationAttribute() : base("Integration") { }
}
I only know how to apply a filter in VS-Test step, as follows:
But not when I'm testing using dotnet:
I only know how to build code coverage using dotnet (and not VS-Test)… I want to do both! How do I:
a) Add the commands to the VS-Test to generate the code coverage, the same as I do for dotnet using the command above.
OR
b) Apply the filter to the dotnet Test step?
Any pointers much appreciated!