User Tools

Site Tools


dev:contributing:qa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:contributing:qa [2015/01/29 11:30] – [Perl Unit Tests] ericksondev:contributing:qa [2023/11/10 18:14] (current) – add OPAC tests sandbergja
Line 8: Line 8:
  
 One of the main goals for the 2.8 series regarding QA tests is encouraging developers to engage in the process and learn how to build tests.  The only requirement is that any commits which modify code that has a functional test structure in place (e.g. database changes -- see "Types of Tests" below) must be accompanied by at least one test that in some way exercises the change.  It does not have to test every facet of the new code.  We're aiming for one step beyond "Hello, World".   One of the main goals for the 2.8 series regarding QA tests is encouraging developers to engage in the process and learn how to build tests.  The only requirement is that any commits which modify code that has a functional test structure in place (e.g. database changes -- see "Types of Tests" below) must be accompanied by at least one test that in some way exercises the change.  It does not have to test every facet of the new code.  We're aiming for one step beyond "Hello, World".  
 +
 +==== Evergreen 2.9 ====
 +
 +As of Evergreen 2.9, the test case expectations include:
 +
 +  * Any time a patch adds or alters a stored procedure, pgTAP tests that exercise its intended functionality should be included.
 +  * A change to database or Perl code that fixes a bug should be  accompanied by a Perl (t or live_t) or pgTAP regression test – or by a statement from the patch author explaining why a test is infeasible without significant refactoring.  In the latter case, it is expected that an extra signoff be obtained before the patch is merged.
 +  * Bugfix patch commit messages should explain how to test the bug it fixes. For example: rather than just write a bare "LP#124565: fix Evergreen's cat-petting functionality", provide something more like:
 +
 +  LP#124565: fix Evergreen's cat-petting functionality
 +  
 +  Evergreen does not do an adequate job of petting cats.  To
 +  reproduce the problem:
 +  
 +  [1] Bring up an Evergreen OPAC and place a cat
 +  in front of it.
 +  [2] Observe that a hand appears and makes waving
 +  motions a centimeter over the cat.
 +  [3] Observe that the cat does not purr.
 +  [4] Apply the patch.
 +  [5] This time, verify that the hand actually makes contact
 +  with the cat.
 +  [6] Expected result: the cat purrs.
 +
 +
  
 ===== Types of Tests ===== ===== Types of Tests =====
 +
 +==== AngularJS Unit Tests ====
 +
 +These test the Web Client apps.
 +
 +  * They are stored in ''Open-ILS/web/js/ui/default/staff/test/''
 +  * See the [[https://code.angularjs.org/1.6.10/docs/guide/unit-testing#additional-tools-for-testing-angularjs-applications|official instructions]] for details.
 +
 +Running the tests:
 +  * See the [[https://evergreen-ils.org/documentation/install/README_3_1.html#install_files_for_web_staff_client|Evergreen README]] for up-to-date details.
 +  * Steps to run the tests as of Evergreen 3.1:
 +
 +  cd $EVERGREEN_ROOT/Open-ILS/web/js/ui/default/staff/
 +  # fetch JS dependencies, described in package.json
 +  npm install
 +  # build, run tests, concat+minify
 +  npm run build-prod   # may not be necessary for running tests
 +  npm run test
 +
 +==== Angular Unit Tests ====
 +
 +See [[dev:angular_dev_best_practices#unit_tests|Evergreen Angular Development Best Practices]]
 +
 +To run on a running Evergreen server:
 +
 +<code sh>
 +cd Open-ILS/src/eg2
 +npm run test
 +</code>
 +
 +==== Angular e2e (end-to-end) Tests ====
 +
 +To run with a GUI:
 +
 +<code sh>
 +cd Open-ILS/src/eg2
 +ng e2e
 +</code>
 +
 +To run without a GUI:
 +
 +<code sh>
 +cd Open-ILS/src/eg2
 +MOZ_HEADLESS=1 ng e2e
 +</code>
 +
 +To run in Chrome instead of Firefox:
 +<code sh>
 +cd Open-ILS/src/eg2
 +npm install --save-dev chromedriver
 +ng e2e --env chrome # with the GUI
 +ng e2e --env chrome-headless # without the GUI
 +</code>
 +
 +For more tips and documentation, visit the [[https://github.com/evergreen-library-system/Evergreen/blob/main/Open-ILS/src/eg2/CHEAT_SHEET.adoc|Angular client cheat sheet]] and the [[https://nightwatchjs.org/v26/|Nightwatch documentation]].
 +
 +==== OPAC Javascript Unit Tests ====
 +
 +To run tests for the javascript in the OPAC:
 +<code sh>
 +cd Open-ILS/web/opac/deps
 +npm i && npm run test
 +</code>
  
 ==== Perl Unit Tests ==== ==== Perl Unit Tests ====
Line 17: Line 105:
   * They are built using Perl's http://perldoc.perl.org/Test/More.html   * They are built using Perl's http://perldoc.perl.org/Test/More.html
   * Files are kept in the Evergreen repository under Open-ILS/src/perlmods/t/.   * Files are kept in the Evergreen repository under Open-ILS/src/perlmods/t/.
-  * Tests are automatically executed when running "make check" in the root of the repositoryafter "configure" and "make" have been run.+  * Tests are run with "make check" in the root of the repository after "configure" and "make" have been run.
  
 For a simple example, see Open-ILS/src/perlmods/t/01-OpenILS-Application.t.  Of note is the following section of code which tests a Perl function in the AppUtils.pm module: For a simple example, see Open-ILS/src/perlmods/t/01-OpenILS-Application.t.  Of note is the following section of code which tests a Perl function in the AppUtils.pm module:
Line 70: Line 158:
  
 The "pgtap" package, which is not part of a standard Evergreen installation, must be installed and the extension must be added to your Evergreen database: The "pgtap" package, which is not part of a standard Evergreen installation, must be installed and the extension must be added to your Evergreen database:
 +
 +Install pgtap from source, the versions in Debian/Ubuntu are not well maintained and are from 2011 when they exist at all. Old versions don't contain all the functions used by Evergreen pgtap tests.
 +
 +  * Download from - http://pgxn.org/dist/pgtap/
 +  * Install Instructions - http://pgtap.org/documentation.html#installation
 +  * Install the package for libtap-parser-sourcehandler-pgtap-perl which provides pg_prove.
  
 <code sh> <code sh>
-sudo apt-get install pgtap # debian/ubuntu version+apt-get install libtap-parser-sourcehandler-pgtap-perl #Debian/Ubuntu provides pg_prove
 psql -U evergreen [other DB connection params] -c "CREATE EXTENSION pgtap;" psql -U evergreen [other DB connection params] -c "CREATE EXTENSION pgtap;"
 </code> </code>
Line 95: Line 189:
 <code sh> <code sh>
 cd Open-ILS/src/sql/Pg cd Open-ILS/src/sql/Pg
-pg_prove -U evergreen [other DB connection params] t_live+pg_prove -U evergreen [other DB connection params] live_t
 </code> </code>
  
dev/contributing/qa.1422549013.txt.gz · Last modified: 2022/02/10 13:34 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.