0

我的问题与 picocontainer 有关,执行测试运行程序时我无法弄清楚我做错了什么. 我的项目包含以下文件 1)1 步骤定义 2)功能文件 2)运行程序文件 4)测试上下文(共享状态文件,这里我提到了 webdriver 和页面对象元素)

POM 文件

<dependencies>
 <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.12</version>
     <scope>test</scope>
 </dependency>
     <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-java</artifactId>
     <version>3.141.5</version>
 </dependency>
 <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.8.0</version>
</dependency>
  <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.8.0</version>
    <scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm-deps -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-jvm-deps</artifactId>
    <version>1.0.6</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.8.0</version>
</dependency>

功能文件 功能:自动端到端测试 描述:此功能的目的是测试 End 2 End 集成。

场景:客户通过搜索购买物品下订单给定用户在主页上当他搜索“连衣裙”并选择第一次购买该物品并从迷你购物车移动到结帐并在结帐页面上输入个人详细信息并放置命令

步骤定义

package stepDefinitions;



import cucumber.TestContext;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;

import pageObjects.HomePage;

public class HomePageSteps {

     TestContext testContext;
     HomePage homePage;

     public HomePageSteps(TestContext context) {
     this.testContext = context;
     homePage = testContext.getPageObjectManager().getHomePage();
     }

     @Given("^user is on Home Page$")
     public void user_is_on_Home_Page(){
     homePage.navigateTo_HomePage(); 
     }

     @When("^he search for \"([^\"]*)\"$")
     public void he_search_for(String product)  {
     homePage.perform_Search(product);
     }

    }

亚军文件

package runners;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;



//import cucumber.api.java.ObjectFactory;T

@RunWith(Cucumber.class)
@CucumberOptions(
    //  junit = "--step-notifications",
        features = "src/test/resources/functionalTests",
        glue= {"stepDefinitions"})



public class TestRunner {


}

测试环境

package cucumber;

import managers.PageObjectManager;
import managers.WebDriverManager;

public class TestContext {
     private WebDriverManager webDriverManager;
     private PageObjectManager pageObjectManager;

     public TestContext(){
     webDriverManager = new WebDriverManager();
     pageObjectManager = new PageObjectManager(webDriverManager.getDriver());
     }

     public WebDriverManager getWebDriverManager() {
     return webDriverManager;
     }

     public PageObjectManager getPageObjectManager() {
     return pageObjectManager;
     }

    }
4

0 回答 0