|
| 1 | +# Neo4j Driver Testing |
| 2 | + |
| 3 | +## Unit Tests |
| 4 | + |
| 5 | +Unit tests **require** to setup the development environment as described at `CONTRIBUTING.md`. |
| 6 | + |
| 7 | +* To run unit tests for the whole project: |
| 8 | + |
| 9 | +```bash |
| 10 | +$ npm run test::unit |
| 11 | +``` |
| 12 | + |
| 13 | +* To run unit tests against only an specify module: |
| 14 | + |
| 15 | +```bash |
| 16 | +$ npm run test::unit -- --scope="name-of-the-package" |
| 17 | +``` |
| 18 | + |
| 19 | +* To run unit tests for each time a file is changed in a package: |
| 20 | + |
| 21 | +```bash |
| 22 | +$ cd ./packages/name-of-package-folder |
| 23 | +$ npm run test::watch |
| 24 | +``` |
| 25 | +Watch is not supported in the package `neo4j-driver`. |
| 26 | + |
| 27 | +**Warning!** When the change spread across multiple package, it might be need to rebuild the project to the changes be propagated before testing. |
| 28 | + |
| 29 | + |
| 30 | +## Testing using Testkit |
| 31 | + |
| 32 | +Tests **require** latest [Testkit 5](https://github.com/neo4j-drivers/testkit/tree/5.0), Python3 and Docker. |
| 33 | + |
| 34 | +Testkit is needed to be cloned and configured to run against the Javascript Lite Driver. Use the following steps to configure Testkit. |
| 35 | + |
| 36 | +1. Clone the Testkit repository |
| 37 | + |
| 38 | +```bash |
| 39 | +$ git clone https://github.com/neo4j-drivers/testkit.git |
| 40 | +``` |
| 41 | + |
| 42 | +2. Under the Testkit folder, install the requirements. |
| 43 | + |
| 44 | +```bash |
| 45 | +$ pip3 install -r requirements.txt |
| 46 | +``` |
| 47 | + |
| 48 | +3. Define some environment variables to configure Testkit |
| 49 | + |
| 50 | +```bash |
| 51 | +$ export TEST_DRIVER_NAME=javascript |
| 52 | +$ export TEST_DRIVER_REPO=<path for the root folder of driver repository> |
| 53 | +``` |
| 54 | + |
| 55 | +By default, Testkit will run against the full version of the driver. |
| 56 | +For testing the `neo4j-driver-lite`, the environment variable `TEST_DRIVER_LITE` should be set to `1`. |
| 57 | +For testing the `neo4j-driver-deno`, the environment variable `TEST_DRIVER_DENO` should be set to `1`. |
| 58 | + |
| 59 | +To run test against against some Neo4j version: |
| 60 | + |
| 61 | +``` |
| 62 | +python3 main.py |
| 63 | +``` |
| 64 | + |
| 65 | +More details about how to use Testkit could be found on [its repository](https://github.com/neo4j-drivers/testkit/tree/5.0) |
| 66 | + |
| 67 | +## Testing (Legacy) |
| 68 | + |
| 69 | +Tests **require** latest [Boltkit](https://github.com/neo4j-contrib/boltkit) and [Firefox](https://www.mozilla.org/firefox/) to be installed in the system. |
| 70 | + |
| 71 | +Boltkit is needed to start, stop and configure local test database. Boltkit can be installed with the following command: |
| 72 | + |
| 73 | +``` |
| 74 | +pip3 install --upgrade boltkit |
| 75 | +``` |
| 76 | + |
| 77 | +To run tests against "default" Neo4j version: |
| 78 | + |
| 79 | +``` |
| 80 | +./runTests.sh |
| 81 | +``` |
| 82 | + |
| 83 | +To run tests against specified Neo4j version: |
| 84 | + |
| 85 | +``` |
| 86 | +./runTests.sh '-e 4.2.0' |
| 87 | +``` |
| 88 | + |
| 89 | +Simple `npm test` can also be used if you already have a running version of a compatible Neo4j server. |
| 90 | + |
| 91 | +For development, you can have the build tool rerun the tests each time you change |
| 92 | +the source code: |
| 93 | + |
| 94 | +``` |
| 95 | +gulp watch-n-test |
| 96 | +``` |
| 97 | + |
| 98 | +If the `gulp` command line tool is not available, you might need to install this globally: |
| 99 | + |
| 100 | +``` |
| 101 | +npm install -g gulp-cli |
| 102 | +``` |
| 103 | + |
| 104 | +### Testing on windows |
| 105 | + |
| 106 | +To run the same test suite, run `.\runTest.ps1` instead in powershell with admin right. |
| 107 | +The admin right is required to start/stop Neo4j properly as a system service. |
| 108 | +While there is no need to grab admin right if you are running tests against an existing Neo4j server using `npm test`. |
0 commit comments