-
Notifications
You must be signed in to change notification settings - Fork 147
Non-atomic integration tests #252
Comments
@roschaefer , isn't this very similar to a situation we had a couple of weeks before? don't remember exactly, but there was a setting of the database config to queue the requests serially vs. working multitasked? |
Nope. You talking about jest's Plus, the test expect the very same state in the database and it's a lot of data, see below 👇 It might be a lot of work to refactor the tests to use factories (set up the required data for each test). Then you can do |
With this commit you can run ``` npm run test-isolated ``` over and over again and the tests should pass. This does not fix the issue mentioned above but it makes it less painful. At least I can make my changes and run all tests exluding those that are not isolated. When I'm done with my changes I can re-import the data and run all the tests, even those that are not isolated. This is what I did to get all the tests passing on my machine: ``` sudo rm /var/lib/neo4j/data/databases/* -r sudo cp -rp ~/Downloads/temp/neo4j-graphql-js/recommendations.db/ /var/lib/neo4j/data/databases/graph.db sudo systemctl restart neo4j.service ``` Very annoying. @johnymontana @michaeldgraham do you know if there is a single command that brings the database into a state where it was *before* running the test case? Something that we could use in a `beforeEach` or `afterEach`? See: neo4j-graphql#252 (comment)
With this commit you can run ``` npm run test-isolated ``` over and over again and the tests should pass. This does not fix the issue mentioned above but it makes it less painful. At least I can make my changes and run all tests exluding those that are not isolated. When I'm done with my changes I can re-import the data and run all the tests, even those that are not isolated. This is what I did to get all the tests passing on my machine: ``` sudo rm /var/lib/neo4j/data/databases/* -r sudo cp -rp ~/Downloads/temp/neo4j-graphql-js/recommendations.db/ /var/lib/neo4j/data/databases/graph.db sudo systemctl restart neo4j.service ``` Very annoying. @johnymontana @michaeldgraham do you know if there is a single command that brings the database into a state where it was *before* running the test case? Something that we could use in a `beforeEach` or `afterEach`? See: neo4j-graphql#252 (comment)
With this commit you can run ``` npm run test-isolated ``` over and over again and the tests should pass. This does not fix the issue mentioned above but it makes it less painful. At least I can make my changes and run all tests exluding those that are not isolated. When I'm done with my changes I can re-import the data and run all the tests, even those that are not isolated. This is what I did to get all the tests passing on my machine: ``` sudo rm /var/lib/neo4j/data/databases/* -r sudo cp -rp ~/Downloads/temp/neo4j-graphql-js/recommendations.db/ /var/lib/neo4j/data/databases/graph.db sudo systemctl restart neo4j.service ``` Very annoying. @johnymontana @michaeldgraham do you know if there is a single command that brings the database into a state where it was *before* running the test case? Something that we could use in a `beforeEach` or `afterEach`? See: neo4j-graphql#252 (comment)
With this commit you can run ``` npm run test-isolated ``` over and over again and the tests should pass. This does not fix the issue mentioned above but it makes it less painful. At least I can make my changes and run all tests exluding those that are not isolated. When I'm done with my changes I can re-import the data and run all the tests, even those that are not isolated. This is what I did to get all the tests passing on my machine: ``` sudo rm /var/lib/neo4j/data/databases/* -r sudo cp -rp ~/Downloads/temp/neo4j-graphql-js/recommendations.db/ /var/lib/neo4j/data/databases/graph.db sudo systemctl restart neo4j.service ``` Very annoying. @johnymontana @michaeldgraham do you know if there is a single command that brings the database into a state where it was *before* running the test case? Something that we could use in a `beforeEach` or `afterEach`? See: neo4j-graphql#252 (comment)
Ideally, we can restructure these tests to use just a Cypher based fixture for setup, rather than dependency on loading a full database dump |
Problem
@johnymontana explained to me in this comment that all the tests are expected to pass. What I have to do is to trash the database and re-import the data for each test run.
And indeed: When I run the the integration tests twice, I see all tests pass and next time some of them failing.
See how this looks like
This is an obvious indicator for so-called non-atomic tests, tests that are not isolated. Running one test case may interfere with another unrelated test case. This is a problem because it deteriorates the quality of the tests, makes flaky behaviour likely and leads to less confidence in the test setup. Plus, it's a not reproducible test setup, it's simply annoying to re-create your database every time.
Solution
Ideal solution:
before
blockHow could you e.g. test the behaviour of this library, say, on an empty database?
The less optimal solution for now might be to check-in a dump of the database currently in use and load the dump prior to each test case.
The text was updated successfully, but these errors were encountered: