|
1 | 1 | # Neo4j Driver Testing |
2 | | - |
3 | 2 | To run driver tests, [Tox](https://tox.readthedocs.io) is required as well as at least one version of Python. |
4 | | -The versions of Python supported by this driver are CPython 3.7, 3.8, 3.9, and 3.10. |
| 3 | +The versions of Python supported by this driver are CPython 3.7 - 3.12 |
5 | 4 |
|
| 5 | +## Testing with TestKit |
| 6 | +TestKit is the shared test suite used by all official (and some community contributed) Neo4j drivers to ensure consistent and correct behavior across all drivers. |
| 7 | +When using TestKit to run tests, you don't have to take care of manually setting up or running unit tests or integration tests as shown below. |
| 8 | +TestKit will take care of that for you and run many other tests as well. |
6 | 9 |
|
7 | | -## Unit Tests & Stub Tests |
| 10 | +TestKit can be found here: https://github.com/neo4j-drivers/testkit. |
| 11 | +See its README for more information on how to use it. |
8 | 12 |
|
9 | | -Unit tests and stub tests (those which make use of the [boltkit](https://github.com/neo4j-contrib/boltkit) stub server) can be run using: |
| 13 | +## Unit Tests |
| 14 | +Unit tests can be run using: |
10 | 15 | ```bash |
11 | | -$ tox |
| 16 | +tox -f unit |
12 | 17 | ``` |
13 | 18 |
|
14 | 19 | ## Integration Tests |
15 | | - |
16 | | -Each test run can also carry out integration tests against a specific version of Neo4j. |
17 | | -To enable integration tests, a server must be made available. |
18 | | -This can be either an existing server listening on the default Bolt port (7687) or a temporary installation from a particular package. |
19 | | -For example: |
20 | | -```bash |
21 | | -$ NEO4J_SERVER_PACKAGE=~/dist/neo4j-enterprise-3.1.1-unix.tar.gz tox |
22 | | -``` |
23 | | - |
24 | | -A web address can be provided as an alternative to a file path: |
25 | | -```bash |
26 | | -$ NEO4J_SERVER_PACKAGE=https://dist.neo4j.org/neo4j-enterprise-3.1.1-unix.tar.gz tox |
27 | | -``` |
28 | | - |
29 | | -If using an existing server, authentication details can be provided in a similar way: |
| 20 | +Integration tests run against a real Neo4j server. |
| 21 | +Hence, you must have a running server (either locally or remotely). |
| 22 | +Make sure there's no data in any of the DBMS's databases and that an empty database `neo4j` is available and is set as the default database. |
| 23 | + |
| 24 | +To allow the tests to connect to the server and choose the right tests to run, you must set the following environment variables: |
| 25 | + * `TEST_NEO4J_HOST`: host name or IP address of the server (e.g., `localhost`) |
| 26 | + * `TEST_NEO4J_PORT`: port number of the server (e.g., `7687`) |
| 27 | + * `TEST_NEO4J_USER`: username for logging into server (e.g., `neo4j`) |
| 28 | + * `TEST_NEO4J_PASS`: password for logging into server (e.g., `my-super-secret-p4$$w0rd`) |
| 29 | + * `TEST_NEO4J_SCHEME`: with wich URL scheme to connect to the server (e.g., `bolt`, `neo4j+ssc`) |
| 30 | + * `TEST_NEO4J_EDITION`: what edition the server is running (e.g., `enterprise`, `community`) |
| 31 | + * `TEST_NEO4J_VERSION`: what version the server is running (e.g., `4.4.36`, `5.22.0`) |
| 32 | + * `TEST_NEO4J_IS_CLUSTER`: whether the remote is a cluster or not (e.g., `true`/`1`, `false`/`0`) |
| 33 | + |
| 34 | +You can then run the integration tests with: |
30 | 35 | ```bash |
31 | | -$ NEO4J_USER=bob NEO4J_PASSWORD=secret tox |
| 36 | +tox -f integration |
32 | 37 | ``` |
33 | | - |
34 | | - |
35 | | -## Code Coverage |
36 | | - |
37 | | -If [Coverage](https://coverage.readthedocs.io/) is installed, test runs automatically add data to a `.coverage` file. |
38 | | -To use this data, ensure that `coverage erase` is executed before commencing a test run; |
39 | | -a report can be viewed after the run with `coverage report --show-missing`. |
40 | | - |
41 | | -## Testing with Testkit |
42 | | - |
43 | | -Tests **require** the latest [Testkit 4.4](https://github.com/neo4j-drivers/testkit/tree/4.4), Python3 and Docker. |
44 | | - |
45 | | -Testkit is needed to be cloned and configured to run against the Python Driver. Use the following steps to configure Testkit. |
46 | | - |
47 | | -1. Clone the Testkit repository—preferably not inside this project's folder |
48 | | - |
49 | | -``` |
50 | | -git clone https://github.com/neo4j-drivers/testkit.git |
51 | | -``` |
52 | | - |
53 | | -2. Under the Testkit folder, install the requirements. |
54 | | - |
55 | | -``` |
56 | | -pip3 install -r requirements.txt |
57 | | -``` |
58 | | - |
59 | | -3. Define some enviroment variables to configure Testkit |
60 | | - |
61 | | -``` |
62 | | -export TEST_DRIVER_NAME=python |
63 | | -export TEST_DRIVER_REPO=<path for the root folder of driver repository> |
64 | | -``` |
65 | | - |
66 | | -To run test against against some Neo4j version: |
67 | | - |
68 | | -``` |
69 | | -python3 main.py |
70 | | -``` |
71 | | - |
72 | | -More details about how to use Teskit could be found on [its repository](https://github.com/neo4j-drivers/testkit/tree/4.4) |
0 commit comments