PHPackages                             hershel-theodore-layton/test-chain - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. hershel-theodore-layton/test-chain

ActiveLibrary[Testing &amp; Quality](/categories/testing)

hershel-theodore-layton/test-chain
==================================

Inferred types for your tests, just append.

v0.3.1(6mo ago)04.2k↑43.9%12MITHackCI passing

Since May 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/hershel-theodore-layton/test-chain)[ Packagist](https://packagist.org/packages/hershel-theodore-layton/test-chain)[ RSS](/packages/hershel-theodore-layton-test-chain/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (4)Versions (8)Used By (12)

Test Chain
==========

[](#test-chain)

*Inferred types for your tests, just append.*

This package was written to replace [HackTest](https://github.com/hhvm/hacktest).

This package is enjoyed best with an assertion library, such as [expect](https://github.com/hershel-theodore-layton/expect).

Usage
-----

[](#usage)

Create a `tests/` directory at the root of your project (next to `vendor/`). This package ships with a `bin/test-chain` script. Do not pass any command line arguments to this script.

This script will create a json file at `tests/test-chain/config.json`. The defaults will likely suffice, but you can change the configuration to your liking. The `tests/run.hack` file template is meant for you to customize, and allows you to do setup work before running the tests.

Let's add your first test. Create `tests/math_test.hack` with this content.

```
namespace YourNamespace;

use namespace HTL\TestChain;

function my_test(TestChain\Chain $chain)[]: TestChain\Chain {
  return $chain->group(__FUNCTION__)
    ->test('addition', () ==> {
      throw new \RuntimeException('not implemented');
    });
}
```

You can discover your tests using `vendor/bin/test-chain`. You can run your tests using `hhvm tests/run.hack`. You can combine these steps with `vendor/bin/test-chain --run`. You should see this output.

```
(0001 / 0001) Fail: YourNamespace\my_test (1 tests)
  - addition: not implemented
---

Tests failed!

```

It is common to want to execute the same test with multiple values. This is called a data-provider test. Here is an example of a such a test:

```

function passing_test(TestChain\Chain $chain)[]: TestChain\Chain {
  return $chain->group(__FUNCTION__)
    ->testWith3Params(
      'division',
      () ==> vec[
        tuple(8, 2, 4),
        tuple(12, 3, 4),
      ],
      ($a, $b, $expected) ==> {
        if ($a / $b !== $expected) {
          throw new \LogicException('math broke');
        }
      },
    );
}
```

Running in CI
-------------

[](#running-in-ci)

When running in CI, you don't want to suddenly discover new tests. If that were allowed, the tests you see in git and what runs in CI wouldn't be the same. By passing `--ci` to `vendor/bin/test-chain`, you assert the chain.hack file was correct and invoke the tests in the same way as with `--run`.

Performance on small test suites
--------------------------------

[](#performance-on-small-test-suites)

By default hhvm will try to jit your tests as you run them, unless overriden in your global hhvm configuration. This is not helpful on most small test suites. `vendor/bin/test-chain-no-jit` behaves exactly like `vendor/bin/test-chain`, but invokes hhvm without the jit. This can shave of a second of your test execution time. It will run a test suite with a handful of fast tests in 0.5 seconds instead of 1.5 seconds.

If you want to run your tests in 0.05 seconds, you can host your tests as a web server. `hhvm -m server -p ` and curl `http://localhost:/tests/test-chain/run.hack`. This will not crawl your tests directory for new test functions. Chained tests on existing functions will be found and run, but new `` functions must be explicitly crawled for with the CLI script.

Upgrades and compatibility
--------------------------

[](#upgrades-and-compatibility)

When the codegen for `chain.hack` changes, all invocations with `--ci` will fail. Running without `--ci` will regenerate this file and further invocations of `--ci` will not fail. If a change to `chain.hack` makes the call in `run.hack`you can regen it with `--update`. Your custom change will have to be reapplied. If none of that works, `--reset` will treat your project as a brand new project, keeping the license comment and the namespace the same for convenience.

These breakages in codegen will **not** require a major version bump.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance76

Regular maintenance activity

Popularity23

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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 ~27 days

Total

7

Last Release

197d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d16d159b7061287c506d4ab44d05ae042bc4ec697116d1bd132a007634d9ff21?d=identicon)[Hershel Theodore Layton](/maintainers/Hershel%20Theodore%20Layton)

---

Top Contributors

[![hershel-theodore-layton](https://avatars.githubusercontent.com/u/81193606?v=4)](https://github.com/hershel-theodore-layton "hershel-theodore-layton (46 commits)")

### Embed Badge

![Health badge](/badges/hershel-theodore-layton-test-chain/health.svg)

```
[![Health](https://phpackages.com/badges/hershel-theodore-layton-test-chain/health.svg)](https://phpackages.com/packages/hershel-theodore-layton-test-chain)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)

PHPackages © 2026

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