Unit tests

From EPrints Documentation
Jump to: navigation, search

Since Eprints 3.2 unit tests have been included in the codebase and can be run by developer and non developer alike.

The tests are not changed very often, but there are quite a few of them covering the existing codebase.

Required packages

Exact requirements for running the tests aren't documented but at this writing, the used packages are these (available from a distribution package or CPAN).

$ grep -h '^use.*::' * |cut -d ' ' -f 2  |sort -u
"EPrints::Test"
"EPrints::Test::XML"
Data::Compare;
Data::Dumper;
Digest::MD5;
EPrints::SystemSettings;
EPrints::Test::RepositoryLog;
EPrints::Test;
LWP::UserAgent;
Test::MockObject::Extends;
Test::MockObject;
Test::More
Test::More;
XML::LibXML::XPathContext;
XML::LibXML;

On RHEL these can be installed by:

yum install eprints perl-Data-Compare perl-libwww-perl perl-Test-Simple perl-Test-MockObject perl-XML-LibXML


Optional packages

There are also optional dependencies (checked with egrep 'require .*::' *):

  • Test::Memory::Cycle
  • XML::DOM
  • XML::GDOME
yum install perl-Test-Memory-Cycle perl-XML-DOM

XML::GDOME is not available on RHEL6 repositories

Storage::LocalCompress is not available on RHEL6 repositories, but if installing it PerlIO::gzip (perl-PerlIO-gzip) is required.


EPrint generating script

EPrints ships testdata//bin/import_rand_data to generate a number of records ( By default creates 1000 prints, 100 publications, 10 publishers and 10 institutions). They don't appear to be required by existing tests but you may find them useful to have during testing anyway and they will be used if available.

This requires [ https://metacpan.org/pod/Text::Lorem Text::Lorem] which is not packaged but can be trivially vendored in to an eprints install.


wget https://st.aticpan.org/source/ADEOLA/Text-Lorem-0.3/lib/Text/Lorem.pm -O perl_lib/Text/Lorem.pm


Once installed it can be run with

./testdata/bin/import_rand_data REPOID

Following this ensure your documents are indexed, either via web or command line

./bin/indexer start --verbose --notdaemon # ^C to stop this after completion

Other configuration

  • A user named "admin" is required for some tests to run, said user does not have to be an admin


Dummy data

For test instances test data can be installed. Without this data set many dozen tests will fail.


Pre supplied data (from testdata/* can be installed with ``import_test_data`` - REPOID is required.

./testdata/bin/import_test_data REPOID

Following this ensure your documents are indexed, either via web or command line

./bin/indexer start --verbose --notdaemon # ^C to stop this after completion

Expected output

Not everything is an error - these items look like problems but aren't.

# Undefined phrase: xxx_invalid (en) at line 24 in /usr/share/eprints/tests/55_phrases.pl