tripal / tripal_doc

Official Documentation for the Tripal Platform
https://tripaldoc.readthedocs.io/en/latest/
GNU General Public License v3.0
2 stars 3 forks source link

Using a Prepared Chado DB in automated testing. #13

Open laceysanderson opened 1 year ago

laceysanderson commented 1 year ago

PR https://github.com/tripal/t4d8/pull/297 adds support for efficient use of chado in automated testing as well as confirms the official prepare task works in the automated testing environment.

We need to add documentation to a https://tripaldoc.readthedocs.io/en/latest/dev_guide/testing.html describing the automated testing environment for Chado.

Specifically we will want to include that when you create a new test which interacts with Chado you should extend ChadoTestBrowserBase. For tests which do not rely on Chado but do rely on Tripal you can extend TripalTestBrowserBase.

Also the ChadoTestBrowserBase will create an empty test chado schema that you can access using $this->chado. If you need tables or records added in the prepare step then you will want to create a new test schema using $prepared_chado = $this->getTestSchema(ChadoTestBrowserBase::PREPARE_TEST_CHADO); and use it directly in your tests instead of $this->chado`. This allows you to check the prepare requirement if you would like to.

laceysanderson commented 1 year ago

We will want to add links / docs for using PHPUnit mock objects in testing.

I've been using:

laceysanderson commented 3 months ago

Here is some documentation I wrote on on the test suite but never completed:

Tripal Test Suite
===================

The Tripal Test Suite is the core set of automated tests distributed with Tripal. These docs will give you an overview of where these tests are located within the codebase and what groups of tests are available.

You can find the tests for any Drupal module in the `tests` directory. Since Tripal core is composed of a number of submodules, you will find our test suite covers a number of directories:

- Tripal Core (`tripal/tests`): these tests are focused on core functionality which is available to all Tripal sites.
- Tripal Chado (`tripal_chado/tests`): here we test all interactions with the Chado database including database management, fields and Chado integration with core APIs such as Tripal DBX.
- Tripal BioDB (`tripal_biodb/tests`): these tests focus on the Tripal BioTask API for managing database focused tasks which can benefit from advanced locking.

You will notice that in each of these test directories, there are a number of subdirectories. These are there by Drupal convention.

- fixtures: this is where any SQL files or mock classes should go for setting up your tests.
- src:

    - Unit: PHPUnit-based tests with minimal dependencies. These should focus on testing specific methods using mock objects and should not require a fully bootstrapped Drupal site.
    - Kernel: PHPUnit-based tests with a bootstrapped kernel, and a minimal number of extensions enabled.
    - Functional: PHPUnit-based tests with a full bootstrapped Drupal instance. These tests include browser based tests and other tests looking at full subsystems.
    - FunctionalJavascript: PHPUnit-based tests that use Webdriver to perform tests of Javascript and Ajax functionality in the browser.

The Tripal Test Suite will eventually test all of the Tripal submodules distributed with Tripal core. Here are the subsystems that currently have automated some testing. You can see the full code coverage for Tripal over at `Code Climate <https://codeclimate.com/github/tripal/tripal/code>`_.

- Tripal DBX:

  This API extends Drupal's Database API to support multiple schema. We have both functional and unit testing for this API which use mock classes in order to test the abstract base classes. Tests can be found in `tripal/tests/Unit/TripalDbx` and `tripal/tests/Kernel/TripalDBX`.

  Code Coverage: greater than 80%