【问题标题】:mvn test throws null pointer exceptionmvn test 抛出空指针异常
【发布时间】:2017-04-26 15:38:42
【问题描述】:

我正在尝试通过 Maven 运行 cucumber+testNG+selenium 。

我的 Runner 文件看起来像这样

//@RunWith(Cucumber.class)
@CucumberOptions(
    format={"pretty", "json:target/report.json"},
    features = {"classpath:cucumber/sample.feature"},               
    glue = "com.stepDefinitions",
    tags="@test"        
    )
public class RunCukesTest extends AbstractTestNGCucumberTests { 

}

我在@BeforeSuite 中初始化我的驱动程序

WebDriver  driver = new FirefoxDriver();

当我在 Eclipse 中通过 TestNG Test 运行它时它工作正常,但是当我使用 mvn test

尝试它时它会抛出空指针异常

我错过了什么吗?

【问题讨论】:

  • 您有任何错误信息吗?还是警告?也许您可以尝试使用mvn -X test 启用跟踪,它可能会打印一些有用的信息

标签: java maven selenium cucumber testng


【解决方案1】:

在@BeforeClass 或@BeforeMethod 中初始化你的webdriver

因为@BeforeSuite 只在套件中运行

【讨论】:

  • 我用@BeforeClass 测试过,出现同样的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-11-22
  • 2020-08-10
  • 2013-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多