PHPUnit未定义函数expectException

PHPUnit未定义函数expectException,phpunit,Phpunit,我尝试运行测试以测试异常情况,但我得到错误-未定义的函数expectException: public function testException($n) { $this->expectException(Exception::class); $this->expectExceptionMessage('Parameter n must be > 0'); $task9 = new Source\Task9();

我尝试运行测试以测试异常情况,但我得到错误-未定义的函数expectException:

 public function testException($n)
    {
        $this->expectException(Exception::class);
        $this->expectExceptionMessage('Parameter n must be > 0');
        $task9 = new Source\Task9();
        $task9->tower_builder($n);
    }
我的composer.json文件是:

{
"name": "codewars/pack",
"description": "Codewars project",
"type": "project",
"require": {
 "phpunit/phpunit": "5.5.*"
},
"autoload": {
"psr-4": {
  "Source\\": "src/"
 }
 }
 }

您的测试类是否扩展了PHPUnit\u框架\u测试用例?