Category (NUnit 2.2)
The Category attribute provides an alternative to suites for dealing
with groups of tests. Either individual test cases or fixtures may
be identified as belonging to a particular category. Both the gui
and console test runners allow specifying a list of categories to
be included in or excluded from the run. When categories are used,
only the tests in the selected categories will be run. Those tests
in categories that are not selected are not reported at all.
This feature is accessible by use of the /include and /exclude arguments
to the console runner and through a separate "Categories" tab in the gui.
The gui provides a visual indication of which categories are selected
at any time.
Test Fixture Syntax
|
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
[Category("LongRunning")]
public class LongRunningTests
{
// ...
}
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture(), Category("LongRunning")>
Public Class LongRunningTests
' ...
End Class
End Namespace
#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;
namespace NUnitTests
{
[TestFixture]
[Category("LongRunning")]
public __gc class LongRunningTests
{
// ...
};
}
#include "cppsample.h"
namespace NUnitTests {
// ...
}
package NUnit.Tests;
import System.*;
import NUnit.Framework.TestFixture;
/** @attribute NUnit.Framework.TestFixture() */
/** @attribute NUnit.Framework.Category("LongRunning") */
public class LongRunningTests
{
// ...
}
|
Test Syntax
|
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class SuccessTests
{
[Test]
[Category("Long")]
public void VeryLongTest()
{ /* ... */ }
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture()>
Public Class SuccessTests
<Test(), Category("Long")> Public Sub VeryLongTest()
' ...
End Sub
End Class
End Namespace
#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;
namespace NUnitTests
{
[TestFixture]
public __gc class SuccessTests
{
[Test][Category("Long")] void VeryLongTest();
};
}
#include "cppsample.h"
namespace NUnitTests {
// ...
}
package NUnit.Tests;
import System.*;
import NUnit.Framework.TestFixture;
/** @attribute NUnit.Framework.TestFixture() */
public class SuccessTests
{
/** @attribute NUnit.Framework.Test() */
/** @attribute NUnit.Framework.Category("Long") */
public void VeryLongTest()
{ /* ... */ }
}
|
|