Unit tests metadata
thekid opened this issue · 0 comments
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
- xp-framework/rfc #16
Related documents
- Declarative Programming in Java
http://www.onjava.com/pub/a/onjava/2004/04/21/declarative.html - NUnit (Unit test framework for C#)
http://www.nunit.org/test.html - Test-Driven Development in .NET
http://www.codeproject.com/dotnet/tdd_in_dotnet.asp - Diff against util/ implementing new behaviour in unit test runner
http://xp-framework.net/downloads/rfc0020-util.diff - Diff against skeleton/ adding metadata to all TestCase classes
http://xp-framework.net/downloads/rfc0020-skeleton.diff