PHPackages                             qpfsoft/deunit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. qpfsoft/deunit

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

qpfsoft/deunit
==============

Debug Unit

v1.3.1(7y ago)0272Apache-2.0PHPPHP &gt;=5.6

Since May 3Pushed 7y agoCompare

[ Source](https://github.com/qpfsoft/deunit)[ Packagist](https://packagist.org/packages/qpfsoft/deunit)[ RSS](/packages/qpfsoft-deunit/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)DependenciesVersions (6)Used By (2)

deunit
======

[](#deunit)

Simple Unit Test!

单元测试编写类继承该抽象方法, 类名*建议*以`Test`后缀.

测试方法*必须*以`test`前缀命名, 并且public权限, 否则不会方法被测试.

提供\[\[setUp()\]\]与\[\[tearDown()\]\]分别在测试方法前后自动执行.

setUp() - 建议编写配置与类初始化, 例如 数据库连接 与 表创建

tearDown() - 可用于释放资源

### 测试返回值

[](#测试返回值)

单元测试内置的断言结果方法, 始终返回true|false布尔值.

也可自行编写结果断言验证, 确保返回true|false即可.

当测试的方法需要打印信息, 建议直接返回.

### 异常捕捉

[](#异常捕捉)

单元测试方法允许抛出异常, Deunit会捕捉异常, 并判定测试失败!

会在测试评估信息中显示异常消息!

示例
--

[](#示例)

```
class FooTest extends TestUnit
{
    public $number;

    /**
     * 建立
     */
    public function setUp()
    {
        $this->number = 5;

        parent::setUp();
    }

    /**
     * 拆除
     */
    public function tearDown()
    {
        $this->number = null;

        parent::tearDown();
    }

    /**
     * 加
     * @return bool
     */
    public function testPlus()
    {
        $result = $this->number + 5;

        return $this->where($result, '=', 10);
    }

    /**
     * 减
     * @return bool
     */
    public function testLess()
    {
        $result = $this->number - 1;

        return $result;
    }

    /**
     * 除
     * @return bool
     */
    public function testExcept()
    {
        throw new Exception('missing');
    }
}

$info = FooTest::runTestUnit();
var_export($info);
```

打印信息

```
array (
  'count' => 3, // 执行测试数量
  'pass' => '67%', // 测试通过率
  'fail' => '33%', // 测试失败率
  'info' =>
  array (
    'testPlus' => 'ok',
    'testLess' => 4,
    'testExcept' => 'missing',
  ),
)
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

2615d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49507188?v=4)[qpfsoft](/maintainers/qpfsoft)[@qpfsoft](https://github.com/qpfsoft)

---

Top Contributors

[![qpfsoft](https://avatars.githubusercontent.com/u/49507188?v=4)](https://github.com/qpfsoft "qpfsoft (10 commits)")

---

Tags

deunit

### Embed Badge

![Health badge](/badges/qpfsoft-deunit/health.svg)

```
[![Health](https://phpackages.com/badges/qpfsoft-deunit/health.svg)](https://phpackages.com/packages/qpfsoft-deunit)
```

###  Alternatives

[fjogeleit/prometheus-messenger-middleware

Prometheus Middleware for the Symfony Messenger Component

2255.2k](/packages/fjogeleit-prometheus-messenger-middleware)[spatie/craft-ray

Easily debug CraftCMS projects

1638.4k](/packages/spatie-craft-ray)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
