// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Xunit.Sdk;
namespace Microsoft.AspNetCore.Testing
{
///
/// Marks a test as "Quarantined" so that the build will sequester it and ignore failures.
///
///
///
/// This attribute works by applying xUnit.net "Traits" based on the criteria specified in the attribute
/// properties. Once these traits are applied, build scripts can include/exclude tests based on them.
///
///
///
///
/// [Fact]
/// [QuarantinedTest]
/// public void FlakyTest()
/// {
/// // Flakiness
/// }
///
///
///
/// The above example generates the following facet:
///
///
///
/// -
/// Quarantined = true
///
///
///
[TraitDiscoverer("Microsoft.AspNetCore.Testing." + nameof(QuarantinedTestTraitDiscoverer), "Microsoft.AspNetCore.Testing")]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class QuarantinedTestAttribute : Attribute, ITraitAttribute
{
///
/// Gets an optional reason for the quarantining, such as a link to a GitHub issue URL with more details as to why the test is quarantined.
///
public string Reason { get; }
///
/// Initializes a new instance of the class with an optional .
///
/// A reason that this test is quarantined.
public QuarantinedTestAttribute(string reason = null)
{
Reason = reason;
}
}
}