Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb. 09, 2010, 12:32:37 PM
52584 Posts in 11677 Topics by 7491 Members
Latest Member: startyourhomebasedbusines
News: Class documentation is handy to learn about component properties, events and methods.
 
The PRADO Community » Prado v3.x » General Discussion » Want to help out testing PRADO 3.1? « previous next »
Pages: [1] Print
Author Topic: Want to help out testing PRADO 3.1?  (Read 2913 times)
Knut
PRADO v3.x Developer
Senior Member
*****

Karma: 11
Offline Offline

Posts: 315



View Profile WWW
« on: Jun. 11, 2007, 09:34:13 PM »

We have a fairly complete functional test suite using Selenium for testing all our WebControls. But PRADO lacks of a complete unit test suite so I've done some work on moving and improving the unit test suite in PRADO 3.1 (trunk), but we still have a long way to go. Therefor I'm looking for someone to help out and I'll be your mentor Smiley

Ok, so I probably should tell some more about what I do. I'm writing all the unit tests using PHPUnit 3. The reason for using PHPUnit 3 over SimpleTest is the command line utility, various output formats, integration with other tools, test reports and code coverage reports.

Writing unit tests also gives you a unique insight in PRADO's inner workings. We have around ~200 unit tests implemented now and ~300 incomplete stubs (the number of uncovered unit tests is much higher).

So after installing PHPUnit 3 you go to tests/unit/ in your framework directory in trunk/ and execute AllTests.php which is a test suite that combine all the other tests.

Code:
/Sites/prado/svn/trunk/tests/unit knut$ phpunit AllTests.php
PHPUnit 3.0.6 by Sebastian Bergmann.

IIIIII..........III......................
.........................................
......................................III
IIIIIIIIII...............................
...IIIIIIIIIIIIIIIII....II............I..
.IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIII..IIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
II.........I....I.IIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIII.......I......
........II..............

Time: 00:06


OK, but incomplete or skipped tests!
Tests: 557, Incomplete: 342.

"I" means "Incomplete" and "." means "test passed". (other: "F" = "Failed" and "S" = "Skipped")

You can also easily create a code coverage report (depends on Xdebug) by running:

Code:
phpunit --report=coverage AllTests.php

which will create a directory "coverage" inside tests/unit/ that you can open with your web browser (see: http://www.urdalen.com/prado/qa/coverage/).

You can also run individual tests:
Code:
cd Collections; phpunit TListTest.php

or all tests inside a package:
Code:
cd Collections; php AllTests.php

The best way to start is taking some of the incomplete tests (marked with "throw new PHPUnit_Framework_IncompleteTestError()"), looking at the other files in the test suite and start testing each function.

So if you are interested in helping out, please give me a PM here on the forum.
Logged

mikl
PRADO v3.x Developer
Platinum Member
*****

Karma: 63
Offline Offline

Posts: 951



View Profile
« Reply #1 on: Apr. 07, 2008, 01:42:25 PM »

I just tried to get a little more insight into testing. Not sure if i find enough time / have enough skills to contribute. But unfortunately i already stumbled at my first step:

Code:
[mike@iwan unit]$ phpunit AllTests.php
PHPUnit 3.0.5 by Sebastian Bergmann.

.................
Fatal error: Call to undefined method TXmlElementListTest::readattribute() in /home/mike/projects/prado/trunk/tests/unit/Xml/TXmlElementListTest.php on line 14

Call Stack:
    0.0002      93496   1. {main}() /usr/bin/phpunit:0
    0.0019     262424   2. require('/usr/share/php5/PHPUnit/TextUI/Command.php') /usr/bin/phpunit:44
    0.0610    4647496   3. PHPUnit_TextUI_Command::main() /usr/share/php5/PHPUnit/TextUI/Command.php:401
    0.3999   22421536   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php5/PHPUnit/TextUI/Command.php:100
    0.4002   22422424   5. PHPUnit_Framework_TestSuite->run() /usr/share/php5/PHPUnit/TextUI/TestRunner.php:247
    0.4002   22422424   6. PHPUnit_Framework_TestSuite->run() /usr/share/php5/PHPUnit/Framework/TestSuite.php:478
    0.4113   22500448   7. PHPUnit_Framework_TestSuite->run() /usr/share/php5/PHPUnit/Framework/TestSuite.php:478
    0.4113   22500448   8. PHPUnit_Framework_TestSuite->runTest() /usr/share/php5/PHPUnit/Framework/TestSuite.php:491
    0.4113   22500448   9. PHPUnit_Framework_TestCase->run() /usr/share/php5/PHPUnit/Framework/TestSuite.php:510
    0.4113   22500448  10. PHPUnit_Framework_TestResult->run() /usr/share/php5/PHPUnit/Framework/TestCase.php:223
    0.4114   22500448  11. PHPUnit_Framework_TestCase->runBare() /usr/share/php5/PHPUnit/Framework/TestResult.php:529
    0.4114   22500448  12. PHPUnit_Framework_TestCase->runTest() /usr/share/php5/PHPUnit/Framework/TestCase.php:243
    0.4114   22500528  13. ReflectionMethod->invoke() /usr/share/php5/PHPUnit/Framework/TestCase.php:300
    0.4114   22500608  14. TXmlElementListTest->testConstruct() /home/mike/projects/prado/trunk/tests/unit/Xml/TXmlElementListTest.php:0

I also tried to run tests directly in Collections/ and got this:

Code:
[mike@iwan Collections]$ phpunit AllTests.php
PHPUnit 3.0.5 by Sebastian Bergmann.

Class AllTests could not be found in AllTests.php.
« Last Edit: Apr. 07, 2008, 01:45:16 PM by mikl » Logged
tof06
PRADO v3.x Developer
Platinum Member
*****

Karma: 83
Offline Offline

Posts: 1027



View Profile
« Reply #2 on: Apr. 07, 2008, 02:02:07 PM »

Are you able to upgrade your phpunit environement ?
Unit tests has been rewritten (2 of them) to be compatible with phpunit 3.1+ (see Changeset 2342), and they won't work with 3.0

If you want to run tests inside a sub directory, the running method is a bit different :
Launch :
Code:
php AllTests.php

Or (for Collections subdir)
Code:
phpunit Collections_AllTests AllTests.php

The php method works, but if you want to send arguments to phpunit (like coverage for ex), you need to use the second form. the Collections_AllTests is the name of the class in AllTests.php
Logged
mikl
PRADO v3.x Developer
Platinum Member
*****

Karma: 63
Offline Offline

Posts: 951



View Profile
« Reply #3 on: Apr. 07, 2008, 02:07:33 PM »

Thanks, that did it.
Logged
Pages: [1] Print 
« previous next »
Jump to: