我真的无法找出问题所在。谁能告诉我我做错了什么。
如果我运行功能文件,我的测试将完美运行。但运行 testng.xml 文件出现错误。
这是步骤定义
package com.example.StepDefinitions;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
public class GoogleStepDefs {
int x = 0;
ChromeDriver driver;
@Given("^Launch Google Home Page$")
// @Test(priority = 1)
public void launchgoogle(){
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com/");
Assert.assertTrue(driver.getTitle().equals("Google"));
x=1;
driver.close();
}
}
这是测试运行器
package com.example;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
//@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"html:target/cucumber-reports/cucumber.html"} ,
features = {"src/test/resource/features/"} ,
glue = {"StepDefinitions"}
)
public class TestRunner extends AbstractTestNGCucumberTests{
}
这是黄瓜特征文件
Feature: Google Test
Scenario: Open Google Page
Given Launch Google Home Page
这是 testng.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite">
<test verbose="2" preserve-order="true" name="G:/Abul Hossain Chowdhury/Projects/testCucumberproject">
<classes>
<class name="com.example.StepDefinitions.GoogleStepDefs"> </class>
</classes>
</test>
</suite>