thomasnordahldk/tester
Composer 安装命令:
composer require thomasnordahldk/tester
包简介
An object oriented approach to testing for PHP.
README 文档
README
An object oriented approach to testing PHP code.
Tester aims to be: easy to learn, light weight, object oriented, and extensible.
Installation
The library is released as a composer package.
composer require --dev thomasnordahldk/tester
Tests
Tests are defined by creating TestCase classes.
class MyTestCase implements TestCase { public function getDescription(): string { return "My new unit test"; } public function run(Tester $tester): void { $tester->assert(true, "This assertion passes!"); $tester->assert(false, "This assertion fails!"); } }
The test case is defined as a description of the test and a run test method.
Docs: Creating a test case.
Test suites
Tests suites are defined by the TestSuite class which is created with a
description and an array of TestCase classes.
$unit_tests = new TestSuite("Unit tests", [new UserUnitTest, AddressUnitTest]);
Docs: Test Suites.
Running tests
The library comes with a native test runner that is run from the command line interface, and outputs a summary of the test.
Which tests to run is defined in the file test.php in the root composer
directory. The file is expected to return an array of test suites.
# test.php $unit_tests = new TestSuite("Unit tests", [new UserUnitTest, new AddressUnitTest]); return [$unit_tests];
$composer-root/~ bin/tester
---------------------------------------------------------------------------
- Unit tests - cases: 2
--- Unit test of User ✔
--- Unit test of Address ✔
---------------------------------------------------------------------------
success: 2, failure: 0, assertions: 8, time: 0.04s
---------------------------------------------------------------------------
For a comprehensive description of the options available for the native test runner script:
Docs: How to run tests.
Inspiration
This library is inspired by the testing library mindplay-dk/testies.
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-29