-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Ensure TempDatabase->build() doesn't tear down the database #69
base: master
Are you sure you want to change the base?
Conversation
…r the testsession start request
@madmatt This approach seems pretty reasonable. The nature of a multi-request test means that it would be very difficult to signal what the 'end' of the test is. We've taken the approach of calling testsession/end when we want to cleanup test state. Interestingly enough, there is a argument that leaving test state might not be so bad see https://docs.cypress.io/guides/references/best-practices.html#Dangling-state-is-your-friend as it could help reproduce issues. you could even be a call to Since this is a change in the current behaviour it might make sense to make that older behaviour configurable in this module? A bit yuck having a config for a config but I guess it is across modules. Currently I'm setting an env var that changes the config in core. This works for us as the test environment is set up in docker so we can add the var as part of the test setup script pretty easily. But I think this change would be more intuitive for anyone picking up this module for the first time. |
I just stumbled across this also...
The main place where you might not want Matt's change would be a behat test execution, where it calls TestEnvironment from within the behat script rather than pageview. I would probably add |
Without this being fixed, here's the approach that @blueo has taken I believe: Set up a config yaml with this:
And then when you want to run tests, set the .env var |
Visiting dev/testsession in a browser and starting a test session doesn't work without this patch, because the temp database is created during
TestSessionEnvironment->createDatabase()
and then immediately deleted once the request finishes (due to the shutdown function registered inTempDatabase->build()
.This PR changes this functionality, so that it does not cleanup the DB upon request exit. This will lead to temp databases lying around, unless you end your testsession, which you should always do anyway (if for no other reason than you would also leave the TESTS_RUNNING.json file lying around)...
I think this is an API change, but I'm not sure how else to get around it, apart from setting it in a project's YML config, which could work, but would also affect other things (e.g. phpunit test runs that use
TempDatabase
etc)