如何在 laravel 中使用 phpunit 测试特定的测试类
2022-08-30 07:09:19
我想在我的项目中测试特定的testClass,因为有很多测试类是失败的,我只想一次测试一个类。
我已经在以下文件夹中创建了测试类:\test\repositories\ApplicationVersionFormat.php
<?php
use App\Repositories\ApplicationVersionFormat;
class ApplicationVersionFormatTest extends \TestCase
{
public function testValidFormat()
{
$version = '1.2.3';
$appVersion = new ApplicationVersionFormat();
$this->assertEquals(true,$appVersion->isValidVersion($version));
}
public function testInvalidFormat()
{
$version = '11.2.3';
$appVersion = new ApplicationVersionFormat();
$this->assertEquals(false,$appVersion->isValidVersion($version));
}
public function testInvalidFormat2()
{
$version = '1.22.3';
$appVersion = new ApplicationVersionFormat();
$this->assertEquals(false,$appVersion->isValidVersion($version));
}
public function testInvalidFormat3()
{
$version = '1.2.33';
$appVersion = new ApplicationVersionFormat();
$this->assertEquals(false,$appVersion->isValidVersion($version));
}
public function testInvalidFormat4()
{
$version = '11.22.33';
$appVersion = new ApplicationVersionFormat();
$this->assertEquals(false,$appVersion->isValidVersion($version));
}
}
所以我已经尝试了这个愚蠢的命令,但这些都不起作用:
-
phpunit "repositories\AppVersionTest"
.=> 无法打开文件“测试/存储库/AppVersionTest.php” -
phpunit "test\repositories\AppVersionTest"
.=> 无法打开文件“测试/存储库/AppVersionTest.php” -
phpunit --filter "repositories\AppVersionTest"
.=> 未执行任何测试! -
phpunit --testsuite "repositories\AppVersionTest"
.=> 未执行任何测试!
任何帮助?谢谢