HEADS UP: PHPUnit support in Moodle 2.3

HEADS UP: PHPUnit support in Moodle 2.3

by Petr Skoda -
Number of replies: 2
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers

Hello,

SimpleTest has served us well but it is time to move to a more actively maintained framework. PHPUnit is the de-facto standard for unit testing in PHP projects. Current plan is to add PHPUnit support in 2.3dev and convert as many tests as possible, SimpleTest support would be probably removed in 2.4dev.

I would like to ask for feedback in MDL-31857, it includes first stage of integration. For now it should be suitable for tests that do not modify database. Support for test cases using database will be added soon.

You can get more information in lib/phpunit/readme.md.

Petr

Average of ratings: -
In reply to Petr Skoda

Re: HEADS UP: PHPUnit support in Moodle 2.3

by Anne Krijger -

Hi Petr,

I'm not quite sure what to give feedback on, so I'll just make some general comments and hope they'll help you.

First off; I would love to have PHPUnit test support as this most likely will bring me one step further in the integration of the build process into Jenkins and Sonar.

I currently use Maven to 'build' my Moodle projects with, using the maven-php-plugin.
I say 'build' because obviously there is not really anything to compile, but there are other pieces of the 'build' process that are handled, like code validation, unit testing, reporting (doxygen, phpdocumentor, etc) and archive assembly including deployment docs and jira-issue lists for releases.

As with other setups the unit testing code has it's own directory.
So next to /main/php/moodle directory I have a /test/php/moodle directory containing *Test.php unit test files.

I would expect there to be one moodle unit test class I could extend when needed.

Given the coding style which says no mixed case should be used(*) I guess it would be *test.php files which extend a class called moodle_unit_test_case or something similar.

I understand that using a separate test directory altogether is more complicated when it comes to test code for plugins, but in my view test code has no business being in-between the 'real' code. I would expect people who download Moodle not to get all the test-classes but the tests to be available separately.

Anne.
(*) I'm still not sure why mixed case is not used and find it to be one of the major challenges when writing Moodle code.

In reply to Petr Skoda

Re: HEADS UP: PHPUnit support in Moodle 2.3

by Matt Gibson -

Awesome! I've just been looking at how to use PHPUnit to drive selenium with PHPUnit_Extensions_Selenium2TestCase so this will be super-handy.