定制 osflab/test 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

osflab/test

Composer 安装命令:

composer require osflab/test

包简介

OSF simple unit test component

README 文档

README

A very quick learning time unit test component, that uses the command line to run the tests. Although it is under development, this component works.

Installation

You need at least php 7.1 and composer to use this component:

sudo apt install composer

From github

Installation:

git clone git@github.com:osflab/test.git
cd test && composer install

Use osflab/test in your app with composer

To use it in your project, just add osflab/test in your composer.json file.

Usage

To run your tests, use the command line:

bin/runtests [directory] [filter]

The test runner find recursively the Test.php files in [directory] (default is current) and run it. The second parameter [filter] can be used to run only certain tests.

Simple example:

bin/runtests

Output:

- \Osf\Test\Test ...................................................... [  OK  ]
- 1 test file(s), 2 tests passed, success ^^

When this component is installed as a dependency of your project, the runtests binary is available in vendor/bin directory.

Example in the Application component project:

vendor/bin/runtests . Acl

Output:

- \Osf\Application\Acl\Test ........................................... [  OK  ]
- \Osf\Application\Config\Test ........................................ [ SKIP ]
- 1 test file(s), 51 tests passed, success ^^

Writing Test.php files

The Test.php file content look like this:

use Osf\Test\Runner as OsfTest;

class Test extends OsfTest
{
    public static function run()
    {
        self::reset();

        // Your test here
        try {
            self::assert(/* condition */, /* [message if fails] */);
            self::assertEqual(/* calculated */, /* expected */, /* [message if fails] */);
            // ...
        }

        // Displays an exception
        catch (\Exception $e) {
            self::assertFalseException($e);
        }

        return self::getResult();
    }
}

统计信息

  • 总下载量: 34
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 18
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2018-02-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固