You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Codeception中跳过整个Cest测试类?

如何在Codeception中跳过整个Cest测试类的所有用例

当然可以直接在类级别设置跳过,不用给每个测试方法逐个加@skip注解。你只需要把@skip注解直接放在类的文档注释里就行,这样整个类里的所有测试用例会全部被跳过。

修改后的代码示例:

/**
 * @skip Skip message: 整个测试类暂时跳过执行
 */
class MyTests{
   public function test1(){
    // Test steps
   }
    
   public function test2(){
     // Test steps
   }
}

如果需要根据特定条件动态跳过整个类(比如环境判断),还可以在类的_beforeClass静态方法里抛出\Codeception\Exception\SkipException,示例如下:

class MyTests{
    public static function _beforeClass()
    {
        // 比如判断当前环境是开发环境就跳过
        if (getenv('APP_ENV') === 'dev') {
            throw new \Codeception\Exception\SkipException('开发环境下跳过整个测试类');
        }
    }

   public function test1(){
    // Test steps
   }
    
   public function test2(){
     // Test steps
   }
}

内容的提问来源于stack exchange,提问作者Summa Tenth

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 08:25:22