Skip to content

Unit tests metadata #20

@thekid

Description

@thekid

Scope of Change

The unit testing API will make use of the new metadata facility described
in xp-framework/rfc #16.

Rationale

Instead of having to having to rely on method names beginning with the
string "test" or having to supply all test methods from "the outside",
test methods can be simply marked with the annotation @test.

Functionality

Basic usage

The "test" tag is used to identify methods to be used as a test. This
attribute tells the framework that a particular method in the test case
is to be run during the unit testing phase.

Example:

<?php
  class ParserTest extends TestCase {

    #[@test]
    function tokenOrder() {
      // ...
    }
  }
?>

Ignoring certain tests

Sometimes when a unit test is not ready for testing, it is good to ignore
that test while still being able to run the other tests. To that end, it
is allowed to set an @ignore attribute on a test method. Just as the name
would imply, this attribute will cause the method or class to be ignored
when the unit tests are run.

Example:

<?php
  class ComplexNumbersTest extends TestCase {

    #[@test]
    function testAddition() {
      // ...
    }

    #[@test, @ignore('Not yet implemented')]
    function testDivision() { }
  }
?>

Dependencies

Related documents

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions