TestAttribute (NUnit 2.0)
The Test attribute marks a specific method inside a class that has already been
marked as a TestFixture, as a test method. For backwards compatibility with
previous versions of Nunit a test method will also be found if the first 4
letters are "test" regardless of case.
The signature for a test method is defined as follows:
public void MethodName()
Note that there must be no parameters. If the programmer marks a test method
that does not have the correct signature it will not be run and it will appear
in the Test Not Run area in the UI that ran the program.
Example:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class SuccessTests
{
[Test] public void Add()
{ /* ... */ }
public void TestSubtract()
{ /* backwards compatibility */ }
}
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture()> Public Class SuccessTests
<Test()> Public Sub Add()
' ...
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] void Add();
};
}
#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() */
public void Add()
{ /* ... */ }
}