我试图使用 Page Factory Model 和 Cucumber 自动化一些示例测试场景,但似乎不明白为什么当我尝试运行单个测试用例时会出现多个驱动程序实例。
当我尝试通过 Runner.java 文件仅运行测试用例 1 时
package execution;
import java.io.File;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "D:\\Eclipse Wokspace\\EcommerceProject\\Features\\Test1.feature",
glue = { "stepDefinition" },
plugin = { "html:target/cucumber-html-report",
"pretty:target/cucumber-pretty.txt", "usage:target/cucumber-usage.json",
"junit:target/cucumber-results.xml","com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
dryRun = false,
monochrome = true,
strict = true)
public class Runner {
@AfterClass
public static void writeExtentReport() {
Reporter.loadXMLConfig(
new File("D:\\Eclipse Wokspace\\EcommerceProject\\src\\test\\resources\\extent-config.xml"));
Reporter.setSystemInfo("User Name", System.getProperty("user.name"));
Reporter.setSystemInfo("Time Zone", System.getProperty("user.timezone"));
Reporter.setSystemInfo("Machine", "Windows 10 " + "64 Bit");
Reporter.setSystemInfo("Selenium", "3.7.0");
Reporter.setSystemInfo("Maven", "3.5.2");
Reporter.setSystemInfo("Java Version", "1.8.0_151");
}
}
湖上湖
相关分类