NullPointerException 而 运行ning 来自 TestRunner,当我 运行 单独来自功能文件时同样有效
NullPointerException while running from TestRunner, same works when I run individually from feature file
测试运行者:
package com.test;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
strict = true,
dryRun = false,
glue={"classpath:com/test/stepDefs/"},
plugin={
"pretty:target/cucumber-pretty.text",
"html:target/cucumber/cucumber.html",
"json:target/cucumber/cucumber.json",
"junit:target/cucumber/cucumber.xml",
},
features={"src/test/resources/Samplefeatures"},
tags = "@Web")
public class TestRunner { }
使用的依赖项
<junit>4.12</junit>
<io.cucumber>4.2.0</io.cucumber>
当我 运行 与功能文件(场景)分开时有效
非常感谢任何帮助。
检查你的胶水和步骤 def 代码(你在运行文件中定义的结构和方式)
看来你的特征应该在这个结构中
/src/test/resources/com/test/
因为你的 stepdefs 在
src/test/java/com/test/stepDefs/
这是我的 AcceptanceIT.java
跑步者文件,似乎工作正常
@RunWith(Cucumber.class)
@CucumberOptions
(
plugin = {
"pretty",
"json:target/AcceptanceTestResults.json"
},
features = "src/test/resources/com/test/",
glue = {"com.test.stepdefs"},
tags = "@post or @get",
publish = true
)
public class AcceptanceIT {
}
测试运行者:
package com.test;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
strict = true,
dryRun = false,
glue={"classpath:com/test/stepDefs/"},
plugin={
"pretty:target/cucumber-pretty.text",
"html:target/cucumber/cucumber.html",
"json:target/cucumber/cucumber.json",
"junit:target/cucumber/cucumber.xml",
},
features={"src/test/resources/Samplefeatures"},
tags = "@Web")
public class TestRunner { }
使用的依赖项
<junit>4.12</junit>
<io.cucumber>4.2.0</io.cucumber>
当我 运行 与功能文件(场景)分开时有效
非常感谢任何帮助。
检查你的胶水和步骤 def 代码(你在运行文件中定义的结构和方式)
看来你的特征应该在这个结构中
/src/test/resources/com/test/
因为你的 stepdefs 在
src/test/java/com/test/stepDefs/
这是我的 AcceptanceIT.java
跑步者文件,似乎工作正常
@RunWith(Cucumber.class)
@CucumberOptions
(
plugin = {
"pretty",
"json:target/AcceptanceTestResults.json"
},
features = "src/test/resources/com/test/",
glue = {"com.test.stepdefs"},
tags = "@post or @get",
publish = true
)
public class AcceptanceIT {
}