Overview
module url | N/A | ||||||||||
git repository | https://bitbucket.org/arrizza-public/test-perl | ||||||||||
git command | git clone git@bitbucket.org:arrizza-public/test-perl.git | ||||||||||
verification report | https://arrizza.com/web-ver/test-perl-report.html | ||||||||||
version info |
|
- repo status: Repo Information
- installation: Common Setup
Summary
ut.pm runs unit tests in perl. It automatically discovers testcases in the source files by looking for testcases in the main:: package that start with 'test'.
Typical output
The output from sample/test.pl should look like:
./doit
==== doit: starting...
===> Test case main::test_should_fail()
FAILED: sample/test.pl(10): test_should_fail()
exp: 1
act: undef
FAILED: sample/test.pl(11): test_should_fail()
exp: 1
act: 0
FAILED: sample/test.pl(12): test_should_fail()
exp: 1
act: ''
FAILED: sample/test.pl(13): test_should_fail()
exp: undef
act: 0
FAILED: sample/test.pl(14): test_should_fail()
exp: 1
act: undef
FAILED: sample/test.pl(16): test_should_fail()
value : abc
prefix: b
===> Test case main::test_should_pass()
Summary:
number of files : 0
number of testcases: 2
number of asserts : 10
number of errors : 6
doit: run_it rc=0
Note that test_should_pass() has no failures, so no stdout warnings show up.
You can use a CLI argument to restrict the testcases to have a particular substring in it:
$ ./doit pass
OK set_env: rc=0
ABRT get_cov_opts: dir does not exist: ./src
OK doit: out_dir: /home/arrizza/projects/web/languages/test-perl/out
==== doit: starting...
===> skipping 'test_should_fail', does not match 'pass'
===> Test case main::test_should_pass()
Summary:
number of files : 0
number of testcases: 1
number of asserts : 4
number of errors : 0
doit: run_it rc=0
Verification
See the ./ver directory for tests that verify the UT functions.
- TP001 - test protocol to check the ut::assert() function
- TP002 - test protocol to check the ut::assert_bool() function
- TP003 - test protocol to check the ut::assert_startswith() function
Note: to verify these functions, the calls may or may not fail. Failing may be the expected behavior and so it is a UT fail, but a verification pass.
Summary: <=== shows summary of the UT failures
number of files : 5
number of testcases: 5
number of asserts : 43
number of errors : 20
---> VER_REPORT: <=== shows summary of the verification failures, if any
---> VER asserts: 82
---> VER failed : 0
Other functions
Currently, this is just a preliminary test of perl.
If it becomes useful, then the following functions will likely be added:
- assert_false()
- assert_not_equal()
- assert_is_undef()
- assert_defined()
- assert_in(value, list)
- assert_not_in(value, list)
- assert_lt()
- assert_le()
- assert_gt()
- assert_ge()
- assert_regex()
- assert_not_regex()
- assert_delta(expected, actual, tolerance)
- assert_not_delta()
- assert_delta_pct()
- assert_not_delta_pct()
These currently do not stop on a failure. If that becomes necessary, then there will be a matching set of functions confirm_xx() which will exit or throw an exception on a failure.