我想要创建一系列可以连续运行的测试,其思想是,如果在运行之前的测试没有通过,那么所有的套件都不会通过。
这听起来像反模式,但我需要测试用户流。
我试过使用数据集,但每次运行测试时,它都会重新启动流。
发布于 2021-07-28 18:30:19
我不确定我要分享的是不是你想要的。您必须使用@depends,这将允许您在它所依赖的测试没有通过时不运行测试。
这是关于它的正式文件。
这就是一个例子:
public function test_user_is_saved()
{
// Test sending data to an endpoint stores the user
}
/**
* @depends test_user_is_saved
*/
public function test_error_is_thrown_on_invalid_input()
{
// Send invalid input (so validator fails)
}如果test_user_is_saved失败,test_error_is_thrown_on_invalid_input将不会运行。你可以用任何测试来链接这个。
发布于 2021-08-01 19:26:24
谢谢!
在对官方包的PRs进行了一些搜索之后,我发现它们使用的是->depends()作为指向这里,所以现在我以这种方式实现了它。
示例:
<?php
use App\User;
it('is the first test', function () {
$this->user = factory(User::class)->make();
$this->assertTrue(true);
return true;
});
// If I remove this test, it works fine.
it('depends on the first test', function ($arg) {
$this->assertTrue($arg);
})->depends('it is the first test');这是关于它的正式变更日志。
https://stackoverflow.com/questions/68564463
复制相似问题