<commit_before>Testing
=======

 - Run unit tests: `mvn test`
 - Run integration tests: `mvn verify`

Unit vs Integration
-------------------
A unit test can access the non-database dependent web server endpoints. An integration test can also access all endpoints.

Writing test cases
------------------
The connect backend is tested using the pippo module `pippo-test` ([link](http://www.pippo.ro/doc/testing.html)).

There are some additional modules that are used to facilitate easier testing of expected behaviour.
 - Some API actions will send an email. It is possible to use a mock `MailClient`, such as `Mailbox` to capture and verify mails. 
 - A `URLParser` class helps with link extraction.

### Unit or Integration test
A test file is run during unit testing if it matches `*Test.java` or `Test*.java`.

Integration tests are matched with `IT*.java` and `*IT.java`.

Integration test phase
---------------
`mvn` creates a neo4j (community) database during the `pre-integration-test` phase. Because of how maven handles tests, the test class names has to contain the letters "IT" (integration test), and can't contain the letters "Test" (unit test). Specifically, unit tests can't access a neo4j database.<commit_msg>Add test framework details to test docs<commit_after>Testing
=======

Connect relies on a number of test steps:

 - maven integration tests (unit tests are supported)
 - circleci continuous integration [link](https://circleci.com/gh/emenlu/connect) on commits and pull requests
 - codecov coverage reports [link](https://codecov.io/gh/emenlu/connect) generated with jacoco

In addition to the integration testing and coverage reporting done by circleci developers are also expected to test their changes locally. The maven commands are:

 - run unit tests only: `mvn test`
 - run unit tests and then integration tests: `mvn verify`

During integration testing an included neo4j server will automatically be started. **An error will be thrown if a unit test case tries to access a route that queries the database.**

Writing test cases
------------------
The connect backend is tested using the pippo module `pippo-test` ([link](http://www.pippo.ro/doc/testing.html)).

There are some additional modules that are used to facilitate easier testing of expected behaviour.
 - Some API actions will send an email. It is possible to use a mock `MailClient`, such as `Mailbox` to capture and verify mails. 
 - A `URLParser` class helps with link extraction.

Detecting test files
--------------------
A test file is run during unit testing if it matches `*Test.java` or `Test*.java`.

Integration tests are matched with `IT*.java` and `*IT.java`.
{'fraction_non_alphanumeric': 0.10877719429857464, 'fraction_numerical': 0.0011252813203300824, 'mean_word_length': 3.7120141342756185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4594929', 'n_tokens_mistral': 690, 'n_tokens_neox': 656, 'n_words': 356}