SimpleTest conversion: Difference between revisions
From MoodleDocs
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
=SimpleTest emulation= | =SimpleTest emulation= | ||
[[Category:Unit testing]] |
Revision as of 19:38, 20 April 2012
Overview
The migration is pretty straightforward:
- create new test file in `xxx/tests/yyy_test.php`
- copy contents of the old test file
- replace
extends UnitTestCase
withextends basic_testcase
andextends UnitTestCaseUsingDatabase
withextends advanced_testcase
- move constructor code to setUp
- fix setUp(), tearDown()
- fix assert syntax
- add $this->resetAfterTest() in advanced test cases that modify database
- add missing global $CFG for includes outside of testcase classes