#82 Providing a way to get the test cases in a TestSuite object

closed
nobody
9
2012-04-17
2011-07-08
iteman
No

We've developed a CLI tool (Stagehand_TestRunner) and an Eclipse plugin (MakeGood) for continuous testing. They work fine with SimpleTest 1.0.1.

Now we are working on SimpleTest 1.1, but our tools fail to work with it since the test cases in a TestSuite object is not provided to external objects.

SimpleTest 1.1alpha3:

class TestSuite {
private $label;
private $test_cases;

SimpleTest 1.0.1:

class TestSuite {
var $_label;
var $_test_cases;

Our Code:

// For more information, please see https://github.com/piece/stagehand-testrunner/blob/master/src/Stagehand/TestRunner/TestSuite/SimpleTestTestSuite.php#L60
class Stagehand_TestRunner_TestSuite_SimpleTestTestSuite extends TestSuite
{
/**
* @var Stagehand_TestRunner_Config
*/
protected $config;

/**
* @return integer
*/
public function countTests()
{
$testCount = 0;
foreach ($this->_test_cases as $testCase) {
$testCount += $this->countTestsInTestCase($testCase);
}

return $testCount;
}

We want to provide a way to get the test cases such as follows:

* Providing a getter method (e.g. getTestCases())
* Or changing the visibility of the $test_cases field to protected

Discussion

  • iteman

    iteman - 2011-07-08
    • priority: 5 --> 9
     
  • Chris Griffing

    Chris Griffing - 2012-04-17

    I understand that a convenience method (getTestCases) would be nice. But, you can access the test_cases using Reflection if you have php5.3+.

    The process in pseudocode is:
    1. Get Reflection Object of TestSuite
    2. Get $test_cases Reflection Property object as $property
    3. SetAccessible on $property
    4. $arrayOfTestCases = $property->getValue(TestSuiteObject);

     
  • iteman

    iteman - 2012-04-17
    • status: open --> closed
     

Log in to post a comment.