-
Improvement
-
Resolution: Fixed
-
Minor
-
2.9.4
-
MOODLE_29_STABLE
-
MOODLE_29_STABLE, MOODLE_30_STABLE
-
MDL-53012-master -
Running cron tasks is only currently possible with the 'And I trigger cron' step.
This step:
- Cannot be used more than once within a Behat scenario (the second time it won't do anything, because cron and/or the required task already ran)
- Is slower than necessary as it runs many tasks
- Means that tests may fail if an unrelated plugin breaks an unrelated cron task
As a result, it's frequently necessary to create custom tasks for a particular plugin that either mess about with the database in order to ensure a task will run on next cron, or else manually run an individual task.
Rather than doing all these custom tasks it would be a lot nicer to have a built-in step that does it. I'll write the code for this and see what people think.
(Obviously this is just something I'd like rather than something we need; creating lots of tasks in all our plugins to do this is a successful workaround.)
The disadvantage of this is that running a single task is slightly less 'realistic' than running the entire cron, but I think that's a fairly limited disadvantage so it would at least be nice to have the option. In addition, running cron in the browser window is not really a realistic situation because it normally runs in the background - using this step, you have the advantage of being able to run a cron task without a user necessarily having to log out and in again, which may actually provide more realistic testing of some situations.
Note: As this is a Behat step change, I am submitting all supported branches.