TestNG注释@BeforeGroups与@AfterGroups不执行的处理
作者:季沐测试笔记
原文地址:https://www.cnblogs.com/testero/p/15113534.html
博客主页:https://www.cnblogs.com/testero
概述
TestNG是一个单元测试框架,具有JUnit4的整个核心的功能,更具有一些新的功能,使其功能更强大,使用更方便。
问题
在学习TestNG框架注解时发现在执行以下的代码
package com.groups;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
public class GroupOnMethod {
@Test(groups = "1")
public void test1(){
System.out.println("测试1");
}
@BeforeGroups("1")
public void BeforeGroup(){
System.out.println("1之前");
}
@AfterGroups("1")
public void AfterGroup(){
System.out.println("1之后");
}
}
出现的结果会是只打印出:
测试1
问题的处理:经过交流沟通发现使用的环境有差异,这段代码在TestNG版本为6.11正常会执行全部的,但在版本7.1.0出现了上述的情况,后来更换版本成功解决此问题
大家可以再7以上的其他版本试试有没此现象大出现,6的版本的应该是都正常的

浙公网安备 33010602011771号