ExplicitAttribute
ExplicitAttribute marks a test or test fixture so that it will
only be run if explicitly executed from the gui or command line
or if it is included by use of a filter. The test will not be
run simply because an enclosing suite is run.
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using System;
namespace NUnit.Framework
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class ExplicitAttribute : NUnitAttribute, IApplyToTest
{
private string reason;
public ExplicitAttribute()
{
reason = "";
}
public ExplicitAttribute(string reason)
{
this.reason = reason;
}
public void ApplyToTest(Test test)
{
if (test.RunState != 0 && test.RunState != RunState.Ignored) {
test.RunState = RunState.Explicit;
test.Properties.Set("_SKIPREASON", reason);
}
}
}
}