Coder Social home page Coder Social logo

brutaltestrunner's Introduction

BrutalTestRunner

Minimalist PHP test runner.

Is a BRUTAL DEV DESIGNED APP -> idea from @4uto3!o6r4mm

Install

git clone [email protected]:PetitCitron/BrutalTestRunner.git
cd BrutalTestRunner
composer install --no-dev

As a Lib, Add in composer.json

"require-dev": {
    "petitcitron/brutaltestrunner": "^2"
  },
"repositories": [
{
  "type": "vcs",
  "url": "https://github.com/PetitCitron/BrutalTestRunner"
}
   ],
composer update

Testing

composer install
php7.4  tests/test.php

Simple - only 3 methods :

$btr = new BrutalTestRunner();
$btr->header(<test_name>) // print header in out
$btr->assertEqual(<expected_val>, <tested_val>, <info_msg>, <strict_mode_test_bool>) // Assert Equals
$btr->footer() // print result in out and correct exit() code

How To use ?

Exemple of tests :

<?php

use PetitCitron\BrutalTestRunner\BrutalTestRunner;

require dirname(__DIR__) . '/vendor/autoload.php';

$btr = new BrutalTestRunner(); // init the runner

$btr->header(__FILE__); // if you want pretty header in terminal

$btr->assertEqual(true, true, 'true == true'); // Only assertEqual test, it's minimalist
$btr->assertEqual(true, is_file(__FILE__), 'script is file');
$btr->assertEqual(true, false, 'true == false', true);
$btr->assertEqual(1, '1', "1 === '1'", false); // assertEqual no strict mode (default)
$btr->assertEqual(1, '1', "1 === '1' strict", true); // assertEqual with strict mode
$btr->assertEqual(true, 1, "true === 1 strict", true); // assertEqual with strict mode

$btr->footer(); // if you want pretty footer n terminal AND good exit code success/fail

Result :

-----------
Brutal test Runner for [test.php]
test 1 :: OK ✔ :: script is file
test 2 :: OK ✔ :: true == true
test 3 :: OK ✔ :: 1 === '1'
test 4 :: FAIL ✖ :: 1 === '1' must, Fail because 'strict' enabled
test 5 :: FAIL ✖ :: true === 1 must, Fail because 'strict' enabled
test 6 :: FAIL ✖ :: true == false must, Fail because 'strict' enabled

-----------
✖ [FAILED] 3 fails, 3 success, 6 total 

See code example in test.php :

php7.4  test.php

Debug Mode

For more debug info you can "on" debug mode

<?php

$btr = new BrutalTestRunner(true);

will stop in first failed test :

-----------
Brutal test Runner for [test.php]
test 1 :: OK ✔ :: script is file
test 2 :: OK ✔ :: true == true
test 3 :: OK ✔ :: 1 === '1'
test 4 :: FAIL ✖ :: 1 === '1'  must, Fail because 'strict' enabled
    1 != 1 
---------------
EXPECT :
1
FOUND :
'1'
---------------
Tests FAILED

brutaltestrunner's People

Contributors

petitcitron avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.