Picocontainer not sharing data w/ step file, tests skipped

I am having trouble running a test using PicoContainer in my project. The project consists of the following files:

  • Step Definition
  • Feature File
  • Runner File
  • Test Context (contains WebDriver and Page Object elements)

POM File

<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>

Feature File

Feature: Automated End2End Tests
Description: The Purpose of this feature is to test End 2 End integration.

Scenario: Customer place an order by purchasing an item from search
Given user is on Home page
When he search for "dress"
And choose to buy the item for first time
And moves to checkout from mini cart
And enter personal details on checkout page and place the order

Step Definition

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);
     }

    }

Runner File

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 {


}

Test Context

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;
     }

    }

I’m having trouble running a test using PicoContainer in my project. The project consists of the following files:

  • Step Definition
  • Feature File
  • Runner File
  • Test Context (contains WebDriver and Page Object elements)

The POM File contains the necessary dependencies for running the test, including cucumber-picocontainer. The Feature File contains the scenario to be tested and the Step Definition contains the steps for the test. The Runner File provides the configuration for the test’s execution and the Test Context contains the WebDriverManager and PageObjectManager objects.

Without knowing the specific issue you are facing, it’s difficult to provide a direct answer. However, some general tips for troubleshooting PicoContainer issues in Cucumber tests include:

  1. Make sure that the cucumber-picocontainer dependency is included in the POM file and is the correct version for your project.
  2. Check that the @CucumberOptions annotation in the Runner File includes the cucumber.picocontainer.dependency-injection parameter with the correct value (such as the package name for your Test Context class).
  3. Verify that your Test Context class is correctly instantiating the PageObjectManager and WebDriverManager objects.
  4. Check that your Step Definition class is correctly using the Test Context object to access the HomePage object.

If you are still having trouble, try searching for specific error messages or consulting the PicoContainer documentation for more information.