2016-09-26 273 views
2

试图实施硒+黄瓜+ Testng而不是Junit。如何使用testng实现和运行黄瓜测试文件

我的查询是

  1. 什么是TestNG中
  2. 的使用@Runwith(Cucumber.class)替代如何运行的类文件,其中包含路径功能文件

package runner; 

import cucumber.api.CucumberOptions; 
import cucumber.api.testng.AbstractTestNGCucumberTests; 


@CucumberOptions(features="src/main/java/testCases/Cucumber/Login_Cucumber.Feature",glue="") 
public class TestRunner extends AbstractTestNGCucumberTests { 

} 

run with testng/cucumber are not appearing

回答

0

安装TestNG Eclipse插件。之后,您应该可以运行TestNG Test

+0

TestNG的是安装在这个日食的例子。要求你不要给这种答案。 –

+0

这个解决方案不起作用,不确定它已经upvoted – vikramvi

1

TestNG的使用@CucumberOptions标签声明参数

@CucumberOptions(plugin = "json:target/cucumber-report.json") 
public class RunCukesTest extends AbstractTestNGCucumberTests { 
} 

@CucumberOptions(features = "src/test/resources/features/Download.feature", 
     glue = "uk.co.automatictester.jwebfwk.glue", 
     format = {"pretty"}) 

检查了这一点:https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng

另外的一个可能的DUP:How to integrate the cucumber in testNG?

+0

我发现这种提示。当我在相同的类中添加@测试注释时,这些正在运行。不知道这是否是正确的方法 –

+0

这是其中的一种方式。 Maven在这种情况下无法实现什么是测试。这两个注释基本上告诉测试什么是测试。 – Sid

+0

为了更清楚,“@test”用于注释一个类/函数作为测试,而TestNG并没有将这个方法视为正常函数。当框架没有像Cucumber这样的其他工具时,在测试套件中使用“@Test”。要充分利用您的功能文件并指定要运行的功能文件,必须使用“@CucumberOptions”注释。 – Sid