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.4.0(3w ago)05.3k↓55.9%12MITHackCI passing

Since May 22Pushed 3w 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 2d ago

READMEChangelog (9)Dependencies (12)Versions (10)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

43

—

FairBetter than 89% of packages

Maintenance95

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity33

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

Recently: every ~83 days

Total

9

Last Release

21d 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 (49 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

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M361](/packages/dms-phpunit-arraysubset-asserts)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)[hackpack/hackunit

An xUnit testing framework for Hack

612.7k14](/packages/hackpack-hackunit)

PHPackages © 2026

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