Intellij IDEA-如何在一个类中运行特定的testng组? [英] Intellij IDEA - How to run specific testng groups in a class?

查看:428
本文介绍了Intellij IDEA-如何在一个类中运行特定的testng组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有Testng插件的最新Intellij IDEA中有一个Maven Java项目.我想在测试类中运行特定的组,而无需为此手动创建xml配置文件.

I have a maven java project in the latest Intellij IDEA with Testng plugin. I want to run specific groups in a test class without manually creating an xml config file for this.

我可以通过运行配置菜单来代替吗?不幸的是,菜单只允许我选择组,类,方法等,而不能选择特定类内的组.

Can I do that through the run configuration menu instead ? Unfortunately, the menu only lets me select groups, classes, methods etc. but not the groups inside a particular class.

推荐答案

让我们假设您具有以下代码示例:

Let's assume you have the following code sample:

import org.testng.annotations.*;

public class Test1 {
  @Test(groups = { "functest", "checkintest" })
  public void testMethod1() {
  }

  @Test(groups = {"functest", "checkintest"} )
  public void testMethod2() {
  }

  @Test(groups = { "functest" })
  public void testMethod3() {
  }
}

要仅运行 checkintest 组,请转到 运行配置 ,创建新的TestNG配置->选择测试种类"组"->选择 checkintest 组. 仅将运行testMethod1,testMethod2.

To run only checkintest group go to Run Configuration, create new TestNG config -> select Test kind "Group" -> select checkintest group. Only testMethod1, testMethod2 will be run.

这篇关于Intellij IDEA-如何在一个类中运行特定的testng组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆