2012-02-23 8 views
5

मैं ऐसे किसी भी बात नहीं पा सके, और मैं यह मौजूद नहीं है अनुमान लगा रहा हूँ ..क्या सेट अप स्थिरता में वर्तमान परीक्षण प्राप्त करना संभव है?

class Test extends PHPUnit_Framework_TestCase { 
    public function setUp() { 
     echo $current_test; // Output a string "testOne" 
    } 

    public function testOne() { 
     // This is the first test; before this test is ran setUp() is called. 
     // The question is, is there any way to know within setUp() what the 
     // current test is? 
    } 
} 

उत्तर

6

$this->name वर्तमान testcase विधि नाम शामिल करना चाहिए। $this->getName() के साथ आप इसे एक्सेस कर सकते हैं (जैसे डेविड कृपया ध्यान दिया)।

https://github.com/sebastianbergmann/phpunit/blob/3.6/PHPUnit/Framework/TestCase.php पर टेस्टकेस के लिए एपीआई देखें। क्या उपलब्ध है इसका एक अनुमान प्राप्त करने के लिए गुणों और उनकी टिप्पणियों पर स्कीम करें।

+1

'$ name' को निजी में बदल दिया गया था, इसलिए आपको' $ this-> getName() 'का उपयोग करने की आवश्यकता होगी। –

+0

उसने ऐसा किया, धन्यवाद! – velo9

+0

दरअसल, स्रोत उपलब्ध होने का सबसे अच्छा तरीका स्रोत है। :) –

संबंधित मुद्दे