Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
/ fbexpect Public archive

A Hack library for writing unit tests expressively

License

Notifications You must be signed in to change notification settings

hhvm/fbexpect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d9c45f8 · Feb 14, 2019

History

69 Commits
Feb 14, 2019
Feb 14, 2019
Feb 14, 2019
Sep 21, 2018
Jul 3, 2017
Oct 18, 2018
Feb 14, 2019
Feb 14, 2019
Feb 14, 2019
Jul 3, 2017
Apr 12, 2018
Sep 25, 2018
Feb 14, 2019
Feb 14, 2019
Jul 31, 2018
Feb 14, 2019

Repository files navigation

Build Status

FBExpect

FBExpect is a standalone unit testing utility based on the notion of assertions from PHPUnit. Starting with 2.x, FBExpect no longer uses PHPUnit as a dependency, and instead implements the assertions directly, and is intentended for use with HackTest.

Examples

Clarity

It is linguistically clear which value is the expected value and which is the actual value:

use function Facebook\FBExpect\expect;

// PHPUnit
$this->assertSame($a, $b);

// FBExpect
expect($b)->toBeSame($a);

Type Refinement

use function Facebook\FBExpect\expect;

// PHPUnit
$this->assertNotNull($x); // Actual test
assert($x !== null); // Tell the typechecker what's going on
$this->assertInstanceOf(Foo::class, $y);
assert($y instanceof Foo);

// FBExpect
$x = expect($x)->toNotBeNull();
$y = expect($y)->toBeInstanceOf(Foo::class);

Installation

FBExpect is installed via composer:

hhvm ~/composer require facebook/fbexpect

License

FBExpect is MIT-licensed.