-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Alexey Ilyin edited this page Mar 8, 2016
·
3 revisions
aiixtest tries to make writing tests really easy. It does not impose specific requirements or format to its test units. Each test unit is merely a valid php script containing some operations; assigned variables are listed, warnings are printed and return value is analysed for a success/failure. Everything is very simple.
Clone https://github.com/ailixter/aiixtest.git, cd to its directory and run demo test suite:
$ cd aiixtest
$ php aiixtest.php demo
that should output the following (except php version):
PHP 5.6.17
----[ init/vars.php ]-----------------------------------------------------------
Initial Vars:
shared $array: array (
);
shared $_hidden: 'hidden shared variable';
o==============================================================================o
| test/newtest.php |
o==============================================================================o
1| <?php
2|
3| $a[1][2][] = 'ok';
4|
5| echo $_hidden;
6|
7| return AIIXTest::assertion($a[1][2][0], !$a[1][2][1]);
--------------------------------------------------------------------------------
hidden shared variable
***** (8): Undefined offset: 1 in /test/newtest.php on 7
--------------------------------------------------------------------------------
Vars after:
shared $array: array (
);
$a: array (
1 =>
array (
2 =>
array (
0 => 'ok',
),
),
);
...
...
Nest you can run specific test:
$ php aiixtest.php demo test mustfail
which should output (with intentional failure):
PHP 5.6.17
----[ init/vars.php ]-----------------------------------------------------------
Initial Vars:
shared $array: array (
);
shared $_hidden: 'hidden shared variable';
o==============================================================================o
| test/mustfail.php |
o==============================================================================o
1| <?php
2|
3| $var = 'a string';
4|
5| return AIIXTest::is_true($var);
6|
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
***** is_true(): got string, not boolean
RETURNED: array(1) {
[0] =>
string(8) "a string"
}
EXPECTED: true
--------------------------------------------------------------------------------
Vars after:
shared $array: array (
);
$var: 'a string';
--------------------------------------------------------------------------------
THE END
At last you can issue:
$ php aiixtest.php -XRW demo
to get just a brief view which of tests haven't been passed (failed):
PHP 5.6.17
***** is_true(): got string, not boolean
test/mustfail.php FAILED!
--------------------------------------------------------------------------------
THE END
See also Command Line