The problem can be narrowed down a little more. My events testcase consists of 4 tests:
- view events
- field events
- filter events
- entry events
The view and field tests loop over all the installed Dataform view and field subplugins respectively.
Each test begins with creating a course and a dataform activity in the course.
Without resetAllData, if I run only this test case, the first test pass and the rest fail on the above mentioned exception. The 'first' in "first test pass" is relative. As is, the view events test pass and the rest fail. If I remove the view events test, then the field events test pass and the rest fail. And so on.
So, it happens with a group of tests even within the same test case. And it is event related issue.