【问题标题】:cucumber using java - Null pointer exception on executing tests from runner classcucumber using java - 从运行器类执行测试时出现空指针异常
【发布时间】:2018-11-17 10:36:19
【问题描述】:

从运行器类执行场景时,我得到空指针执行。当我从功能文件执行然后测试执行没有任何错误时,我使用标签来运行场景,我已经在 runner 类中提到了标签,请让我知道可能是什么原因。

Runner类代码:

@RunWith(Cucumber.class) 
@CucumberOptions( features={"Features"} ,glue={"project.stepdef"} ,tags = {"@chrome","@smoke"} , format = {"pretty", "html:target/site/cucuber-pretty","json:target/site/cucumber.json"} // ,monochrome = true ) 
public class CucumberRunner 
{ 

}

【问题讨论】:

  • 试试this
  • 嗨 soufrk,谢谢,但是当我运行功能文件时我没有得到空指针,我只有在尝试运行 Runner 类时才得到它
  • 能否请您粘贴一些来自 runner 类的代码?
  • @RunWith(Cucumber.class) @CucumberOptions( features={"Features"} ,glue={"project.stepdef"} ,tags = {"@chrome","@smoke"} , format = {"pretty", "html:target/site/cucuber-pretty","json:target/site/cucumber.json"} // ,monochrome = true ) public class CucumberRunner { }
  • 您能否在您的问题中添加格式正确的代码。从您上面的评论看来,您正在评论 (//) 跑步者中的某些内容?

标签: java selenium selenium-webdriver cucumber


【解决方案1】:

您需要对runner 类进行一些小的调整,如下所示:

import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class) 
@CucumberOptions( 
                    features="Features",
                    glue="stepdef",
                    tags = {"@chrome","@smoke"}, 
                    plugin = {"html:target/cucumber-html-report", 
                              "pretty:target/cucumber-pretty.text",
                              "json:target/cucumber.json"},
                ) 
public class CucumberRunner {}

【讨论】:

  • 这就是我的跑步者课程的样子,但是当我在评论中发布时,它显示为普通文本
  • @testerautomation 我已经做了一些修改密切关注,否则只需复制/粘贴并让我知道状态
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-18
  • 1970-01-01
  • 1970-01-01
  • 2014-05-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多