如何将Cucumber与TestNG示例集成?

时间:2015-08-13 20:02:33

标签: java cucumber testng

我正在尝试使用cucumber-testng,看起来很简单。到目前为止,我已经使用gradle安装了以下软件包:

compile 'info.cukes:cucumber-testng:1.2.2'(带有testng的黄瓜)
compile 'info.cukes:cucumber-java:1.2.4'(java现在识别黄瓜注释)
cucumberRuntime 'info.cukes:cucumber-groovy:1.1.6'(运行黄瓜测试)

如何运行这些测试?通过命令gradle cucumber运行此错误时,我看到了错误。

我在java中的测试大纲如下:
的src /测试/资源/特征/ Structured.feature 的src /测试/ JAVA /测试/ httpapi /结构/ StructuredFeatureRunner.java

package test.httpapi.structure;  

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


@CucumberOptions(features = "src/test/resources/features/Structured.feature",
              glue = "test.httpapi.structure",
              format = {"pretty"})
public class StructuredFeatureRunner extends AbstractTestNGCucumberTests {

}

1 个答案:

答案 0 :(得分:0)

我解决了我遇到的上述问题。这是gradle插件的一个问题。我现在在堆栈跟踪中看到我失败的黄瓜测试。

Scenario: Create Structured Store schema in xyz # Structured.feature:4
Given Structured Store object logged into silk  # StructuredStoreApiTests.Structured_Store_object_logged_into_Silk()
When i use api createStructuredRepo                # StructuredStoreApiTests.i_use_api_createStructuredRepo()
  java.lang.NullPointerException
    at rapture.httpapi.structure.StructuredStoreApiTests.i_use_api_createStructuredRepo(StructuredStoreApiTests.java:59)
    at ✽.When i use api createStructuredRepo(Structured.feature:6)

Then i should see schema created in xyz       # StructuredStoreApiTests.i_should_see_schema_created_in_XYZ(Boolean)

Failed scenarios:
Structured.feature:4 # Scenario: Create Structured Store schema in xyz

1 Scenarios (1 failed)
3 Steps (1 failed         , 1 skipped, 1 passed)
0m0.137s

java.lang.NullPointerException
at rapture.httpapi.structure.StructuredStoreApiTests.i_use_api_createStructuredRepo(StructuredStoreApiTests.java:59)
at ✽.When i use api createStructuredRepo(Structured.feature:6)