Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a Prepared Chado DB in automated testing. #13

Open
laceysanderson opened this issue Nov 7, 2022 · 2 comments
Open

Using a Prepared Chado DB in automated testing. #13

laceysanderson opened this issue Nov 7, 2022 · 2 comments

Comments

@laceysanderson
Copy link
Member

PR tripal/t4d8#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
Copy link
Member Author

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

I've been using:

@laceysanderson
Copy link
Member Author

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%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant