r75281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75280‎ | r75281 | r75282 >
Date:18:07, 23 October 2010
Author:mah
Status:ok (Comments)
Tags:
Comment:
Use more descriptive names for the test methods.
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/SampleTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/SampleTest.php
@@ -14,7 +14,14 @@
1515 function tearDown() {
1616 }
1717
18 - function testEqual() {
 18+ /**
 19+ * Name tests so that PHPUnit can turn them into sentances when
 20+ * they run. While MediaWiki isn't strictly an Agile Programming
 21+ * project, you are encouraged to use the naming described under
 22+ * "Agile Documentation" at
 23+ * http://www.phpunit.de/manual/3.4/en/other-uses-for-tests.html
 24+ */
 25+ function testTitleObjectStringConversion() {
1926 $title = Title::newFromText("text");
2027 $this->assertEquals("Text", $title->__toString(), "Title creation");
2128 $this->assertEquals("Text", "Text", "Automatic string conversion");
@@ -39,15 +46,15 @@
4047 }
4148
4249 /**
43 - * @dataProvider provideTitles()
 50+ * @dataProvider provideTitles
4451 * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.dataProvider
4552 */
46 - public function testTitleCreation($titleName, $ns, $text) {
 53+ public function testCreateBasicListOfTitles($titleName, $ns, $text) {
4754 $title = Title::newFromText($titleName, $ns);
4855 $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
4956 }
5057
51 - public function testInitialCreation() {
 58+ public function testSetUpMainPageTitleForNextTest() {
5259 $title = Title::newMainPage();
5360 $this->assertEquals("Main Page", "$title", "Test initial creation of a title");
5461
@@ -66,23 +73,20 @@
6774 * testTitleDepends is whatever testInitialCreatiion returned.)
6875 */
6976 /**
70 - * @depends testInitialCreation
 77+ * @depends testSetUpMainPageTitleForNextTest
7178 * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.depends
7279 */
73 - public function testTitleDepends( $title ) {
 80+ public function testCheckMainPageTitleIsConsideredLocal( $title ) {
7481 $this->assertTrue( $title->isLocal() );
7582 }
7683
7784 /**
78 - * If the code you're testing can produce Exceptions, you can also
79 - * test for them. In the following example, the test expects a
80 - * MWException containing the string "object" in the message..
81 - */
82 - /**
8385 * @expectedException MWException object
8486 * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.expectedException
8587 */
86 - function testException() {
 88+ function testTitleObjectFromObject() {
8789 $title = Title::newFromText(new Title("test"));
 90+ $this->assertEquals( "Test", $title->isLocal() );
8891 }
89 -}
 92+ }
 93+

Comments

#Comment by Hashar (talk | contribs)   15:31, 24 October 2010

The --testdox looks fun. I will try to keep this in mind for test writing. Thanks!

Status & tagging log