Closed ScottFreeCode closed 3 years ago
For what it's worth I'm discovering this reproduces inconsistently. Sometimes using mocks reset
fixes it, sometimes it doesn't.
As far as I've noticed it doesn't happen in the first place if I'm only running all tests, though, so it still seems to have something to do with running an individual test (or perhaps with doing something else after running an individual test).
(It would be nice if there were no need to run mocks reset
ever because it would always reset before running a test, whether running all or individual, and merely would not reset after an individual test.)
@ScottFreeCode You shouldn't have to run mocks reset
unless you are doing exploratory testing and want to revert mocks to their default state. Mocks should always get reset to their default state before a test is ran (all and individual)
@ScottFreeCode Oh boy! I spent way too much time on this before realizing it's doing exactly what it's supposed to! When running an individual test, Touchstone will not reset any mocks. This is a feature allowing the user to inspect mocks manually and track down bugs. Mocks are always reset before tests are ran so it will not affect tests in any way.
Mocks are always reset before tests are ran so it will not affect tests in any way.
This is the part that's not happening. Once it gets into the bad state, running tests (either individually or all tests) doesn't run them against the initial state of the DB.
Is it possible the initial DB snapshot gets replaced by a snapshot of the DB after the individual test (or before running the subsequent test), such that it is resetting but is now resetting to a state from after the test? It should only save the DB snapshot at the end of services start
(of course, it also should reset the DB before beginning services start
so saving the state at the end cannot pick up any test state).
For reproducing, I've noticed I seem to be able to avoid it if:
mocks reset
after the individual test even though I shouldn't have to.(I also haven't tried whether it still happens if I use the mysql defaults yaml instead of the service's migrations, i.e. set the snapshot option to false
; since we got the snapshot option I've always preferred it.)
That suggests it might be reproducible by:
mocks reset
.Ah you're right!
When running Touchstone Develop with
snapshot_databases: true
, after running an individal test, the database is no longer reset when runningmocks reset
or running all tests.I'm not certain whether the reset stops happening or whether the snapshot gets overwritten (which would start getting reset to after the test state).