A lot of Moodle's Behat tests repeatedly test navigating around Moodle before getting to the feature they really want to test. For example:
And I log in as "teacher"
And I am on "Course 1" course homepage
And I follow "Quiz 1"
And I follow "Attempts: 1"
And I follow "Review attempt"
This is bad for several reasons:
- When the Moodle navigation structure changes, all our Behat tests break. This is why, at one point, the 'I am on "Course 1" course homepage' step had to be introduced to fix one breakage. The breakage that caused the '... in current page administration' to be created is another example.
- It makes the test take longer to run, becuase you have to load a whole lot of pages that you are not interested in testing.
So, I think that we should have a step to go straight to the feature you want to test. (Of course, we should also have automated tests for how Navigation works, but we should test that once, not in every scenario.) I had a go at implementing this over at MDL-66335 / https://github.com/timhunt/moodle/compare/master...MDL-66335.
However, while the principle seems sound, I think the details need to be a bit better. In particualr, the steps like the following are not very human-readable.
And I am on "mod_quiz" "Quiz 1" "edit" And I am on "mod_quiz" "Quiz 1/student/1" "attempt review"
I am posting here in the hope that some people will look at what I have done, and have some good suggestions for how to make it better. Thanks.