Skip to content

A unit testing framework for Hack

License

Notifications You must be signed in to change notification settings

PranayAgarwal/hacktest

 
 

Repository files navigation

Build Status

HackTest

HackTest is a pure Hack alternative to PHPUnit. In order to use this framework, you must migrate assert calls to use the expect API.

Usage

bin/hacktest [OPTIONS] PATH [PATH ...]

Examples

"I want to test all files in a directory"

$ bin/hacktest tests/clean/exit/

...

Summary: 3 test(s), 3 passed, 0 failed, 0 skipped, 0 error(s).

"I want to run all tests in a specific file"

$ bin/hacktest tests/dirty/DirtyAsyncTest.php

FFF

1) DirtyAsyncTest::testWithNonNullableTypesAsync
Failed asserting that Array &0 (
    0 => 1
    1 => 'foo'
) is not identical to Array &0 (
    0 => 1
    1 => 'foo'
).

/fakepath/hacktest/tests/dirty/DirtyAsyncTest.php(22): Facebook\FBExpect\ExpectObj->toNotBeSame()
/fakepath/hacktest/src/Framework/HackTestCase.php(43): DirtyAsyncTest->testWithNonNullableTypesAsync()

2)...

Summary: 3 test(s), 0 passed, 3 failed, 0 skipped, 0 error(s).

For an example in verbose mode, see example.txt

Installation

This project uses function autoloading, so requires that your projects use hhvm-autoload instead of Composer's built-in autoloading; if you are not already using hhvm-autoload, you will need to add an hh_autoload.json to your project first.

$ composer require hhvm/hacktest

Principles

  • Test files must end in 'Test.php' or 'Test.hh'
  • Test classes must extend HackTestCase
  • Class names must match base filenames
  • Only test methods and data providers can be public
  • Test methods must begin with 'test'

Contributing

See CONTRIBUTING.md.

License

The HackTest framework is MIT-licensed.

About

A unit testing framework for Hack

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Hack 99.9%
  • Shell 0.1%