Skip to content
airstandley edited this page Jun 19, 2018 · 2 revisions

Test (Enabled = True)

Methods marked with the Test attribute will be automagically added to the test run. Enabled can be set to False to quickly disable tests (Note: This is different to marking a test with the Ignore attribute ). Methods that require parameters will need a TestCase attribute as well, to specify the arguments.

Attributes

A test may be marked with the Category attribute to mark the test as belonging to a specific category of tests. This is useful when filtering tests.

A test may be marked with the Ignore attribute which will skip that test.

A test may be marked with the TestCase attribute to specify test data to pass to the test as parameters. Multiple TestCase attributes can be added to specify different data.

A test may be marked with the MaxTime attribute to specify a maximum duration that the test should take to run.

A test may be marked with the IgnoreMemoryLeaks attribute to ignore memory leaks that occur in the test. By default, if a test is successful and produces a memory leak it will be reported.

A test may be marked with the RepeatTest attribute to repeat the test some number of times. (Note: If [RepeatTest(0)] is used then the test will be skipped and behave as if the Ignore attribute was used.)

A test may be marked with the WillRaise attribute to mark a test which will raise an exception. The test will fail if the exception is not raised.

Examples

[TestFixture]
TMyExampleTests = class
public
  [Test]
  [Category("ExampleTests")]
  procedure Test_Something_Works;
  [Test]
  [TestCase("Case 1", "1,2");
  [TestCase("Case 2", "2,3");
  procedure Test_That_Takes_Data(const AInput: Integer; AResult: Integer);
  [Test]
  [Ignore("This is broken right now")]
  procedure Test_That_Needs_Fixing;
  [Test(False)]
  procedure Test_That_Is_Deprecated;
Clone this wiki locally