Warning: unexpected database modification, resetting DB state

Re: Warning: unexpected database modification, resetting DB state

by Davo Smith -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Nothing should persist between separate unit tests (if it does, then there is a bug in your tests) - it should be possible to run each test separately and get exactly the same results as running all of them together.

You can write helper functions (not called test_xx) which could be called from multiple tests, if you need common setup between tests (or use the setUp() function is you are wanting some same configuration for all of the tests in the file). But if you want to create a user and a course and then enrol the user in the course, then this all needs to be done within a single test.
Average of ratings: Useful (2)