简体   繁体   中英

PHPStorm 4.0 - unable to run PHPUnit on a single class/method

I am having a problem with my PHP project (using the Kohana 3.2 framework) in PHPStorm 4.0.3. When setting up PHPUnit with the Class or Method scope, it is not able to detect the class from the specified unit testing file if the test class extends from Unittest_Database_Testcase .

For example, I could not test the below class because the Choose Test Class dialog box displays "Nothing to show".

/**
 * Class cannot be chosen.
 */
class A_Test extends Unittest_Database_Testcase {
    public function test_something() { /* ... hence this method test cannot be chosen */ }
}

However, if the file extends from Unittest_Testcase , the class (and subsequently the method) can be detected by PHPStorm and I was able to run the test.

class A_Test extends Unittest_Testcase {
    public function test_something() {}
}

I suspect the reason is that PHPStorm is yet to support running database testing individually. Is there a way to get around this?

Note: I have no problems with running the entire test suite, however, I am concerned that the number of tests are growing. It takes roughly half a second to run a single database test (due to the queries involved) hence it will be very time-consuming to run the entire test suite every time I need to verify a newly-written test is working properly.

For anyone who missed it, the OP found the answer and posted it in the comments...

I had to manually include Abstract_Class in the bootstrap file. Probably because it was not included automatically when PHPUnit was pointed to the test file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM