【发布时间】:2021-10-19 01:49:59
【问题描述】:
我正在运行 PHPUnit,并且有一个包含一些测试的类
class TestVideo extends BaseTest
{
public function setUp()
{
//etc...
}
public function testA()
{
.....;
}
public function testB()
{
.....;
}
}
如果我扩展这个类,所有测试都将在派生类中运行。
class TestPhoneVideo extends TestVideo
{
}
如果我只希望testB 在TestPhoneVideo 中运行,而不是testA,该怎么办?
【问题讨论】:
-
BaseTest不是来自 PHPUnit。如果您使用的是 PHPUnit,那么TestVideo应该是VideoTest并且TestPhoneVideo应该是PhoneVideoTest(Test后缀而不是前缀)。 -
我认为你对继承的想法是错误的,继承某些功能而不是其他功能与你继承功能的想法相反,因为它是基类的一种类型。
标签: php unit-testing phpunit