Legacy Documentation. View NUnit 3 Documentation

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.


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

  public class SuccessTests
    [Test] public void Add()
    { /* ... */ }

    public void TestSubtract()
    { /* backwards compatibility */ }