Skip to content

Explicit Attribute

Charlie Poole edited this page Jan 31, 2016 · 10 revisions

The Explicit attribute causes a test or test fixture to be skipped unless it is explicitly selected for running. The test or fixture will be run if it is selected by name or if it is included by use of a filter. Note that a not filter, which excludes certain tests, is not treated as an explicit selection and never causes an explicit test to be run.

An optional string argument may be used to give the reason for marking the test Explicit.

If a test or fixture with the Explicit attribute is encountered in the course of running tests, it is skipped unless it has been specifically selected by one of the above means. The test does not affect the overall result of the test run. Explicit tests are displayed in the gui as skipped.

Test Fixture Syntax

#####C\# ##### ```C# namespace NUnit.Tests { using System; using NUnit.Framework;

[TestFixture, Explicit] public class ExplicitTests { // ... } }


#####Visual Basic

```VB
Imports System
Imports Nunit.Framework

Namespace Nunit.Tests

  <TestFixture(), Explicit()>
  Public Class ExplicitTests
    ' ...
  End Class
End Namespace

#####C++

using namespace System;
using namespace NUnit::Framework;

namespace NUnitTests
{
  [TestFixture]
  [Explicit]
  public __gc class ExplicitTests
  {
    // ...
  };
}

#include "cppsample.h"

namespace NUnitTests {
  // ...
}

Test Syntax

#####C# #####

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  public class SuccessTests
  {
    [Test, Explicit]
    public void ExplicitTest()
    { /* ... */ }
}

#####Visual Basic

Imports System
Imports Nunit.Framework

Namespace Nunit.Tests

  <TestFixture()> Public Class SuccessTests
    <Test(), Explicit()> Public Sub ExplicitTest()
      ' ...
    End Sub
  End Class
End Namespace

#####C++

#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;

namespace NUnitTests
{
  [TestFixture]
  public __gc class SuccessTests
  {
    [Test][Explicit] void ExplicitTest();
  };
}

#include "cppsample.h"

namespace NUnitTests {
  // ...
}
Clone this wiki locally