Difference between revisions of "Unit Testing"
From WormBaseWiki
Jump to navigationJump to search (Basic unit testing description.) |
(Added GBrowse comparative test explanation.) |
||
Line 4: | Line 4: | ||
# run tests of the REST API: <code>perl t/rest.t</code> | # run tests of the REST API: <code>perl t/rest.t</code> | ||
# run tests of the WormBase Perl API: <code>API_TESTS=1 perl t/api.t</code> | # run tests of the WormBase Perl API: <code>API_TESTS=1 perl t/api.t</code> | ||
+ | # run comparative GBrowse tests: <code>perl --base http://your.url.org:1234/cgi-bin/gb2/gbrowse</code> | ||
'''Successful tests''' are preceded by an "ok". For example: | '''Successful tests''' are preceded by an "ok". For example: | ||
Line 29: | Line 30: | ||
</pre> | </pre> | ||
− | === Unit Testing Framework: How it works / Write your own === | + | === API Unit Testing Framework: How it works / Write your own === |
Unit tests are | Unit tests are | ||
Line 35: | Line 36: | ||
* based on [http://perldoc.perl.org/Test/More.html Test::More]. | * based on [http://perldoc.perl.org/Test/More.html Test::More]. | ||
* run on a fully populated WormBase database backend. | * run on a fully populated WormBase database backend. | ||
− | * start (and stop) a Catalyst web server (random port between 28,000 and 31,999) | + | * API tests: start (and stop) a Catalyst web server (random port between 28,000 and 31,999) |
'''Unit test templates''' are available as | '''Unit test templates''' are available as | ||
Line 46: | Line 47: | ||
# create a copy of <code>template.t</code> within the same directory; choose a descriptive filename | # create a copy of <code>template.t</code> within the same directory; choose a descriptive filename | ||
# make appropriate changes to the newly created file | # make appropriate changes to the newly created file | ||
+ | |||
+ | === Comparative Testing Framework: GBrowse === | ||
+ | |||
+ | Comparative GBrowse tests are | ||
+ | |||
+ | * based on a reference image set (one image per species, per track, per example landmark) | ||
+ | * comparing a live <code>gbrowse_img</code> rendering to the respective reference image |
Revision as of 19:41, 19 July 2013
Executing Unit Tests
- change directory into your Github Website clone.
- run tests of the REST API:
perl t/rest.t
- run tests of the WormBase Perl API:
API_TESTS=1 perl t/api.t
- run comparative GBrowse tests:
perl --base http://your.url.org:1234/cgi-bin/gb2/gbrowse
Successful tests are preceded by an "ok". For example:
ok 1 - require 't/rest_tests/template.t'; ok 1 - port open 1..1 ok 2 - test_port_open
How to read the output: The first "ok 1" means that the first executed test require ...
completed sucessfully. "ok 2" shows that the second test was also successful, where sub-tests (i.e., tests within the test_port_open
Perl sub) are shown above as indented lines. The interval "1..1" denotes the tests were run within test_port_open
.
Failed tests are preceded by a "not ok" and a short description is displayed that explains why the test failed (lines preceded by "#"). For example:
not ok 1 - port open # Failed test 'port open' # at t/rest_tests/template.t line 53. # got: undef # expected: anything else 1..1 # Looks like you failed 1 test of 1. not ok 2 - test_port_open
API Unit Testing Framework: How it works / Write your own
Unit tests are
- based on Test::More.
- run on a fully populated WormBase database backend.
- API tests: start (and stop) a Catalyst web server (random port between 28,000 and 31,999)
Unit test templates are available as
t/rest_tests/template.t
for writing REST API testst/api_tests/template.t
for writing WormBase Perl API tests
New unit tests should be using the following workflow:
- create a copy of
template.t
within the same directory; choose a descriptive filename - make appropriate changes to the newly created file
Comparative Testing Framework: GBrowse
Comparative GBrowse tests are
- based on a reference image set (one image per species, per track, per example landmark)
- comparing a live
gbrowse_img
rendering to the respective reference image