'Cucumber With JUnit java.lang.ExceptionInInitializerError

I'm new to the UnitTesting and Cucumber, and today I tried to implement a simple example from a tutorial in Intelij and Eclipse and I got the same error when I try run the TestRunner.java.

My pom.xml:

<dependencies> 
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.5</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.5</version>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
</dependency>

File .feature

   Feature: User Login
  User should be able to login using valid credentials


  Scenario: Testing login with valid credentials
    Given I am on login page
    When I enter username as "jsmith" and password as "demo1234"
    And I submit login page
    Then I redirect to user home page

TestRunner.java

    package com.unit.runner;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:login/LoginTest.feature",
glue = "com.unit.runner.steps")
public class TestRunner {

}

Steps

import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class StepDefinationSteps {
    
    @Given("^I am on login page$")
    public void i_am_on_login_page() throws Throwable {
        System.out.println("open login page url");
    }

    @When("^I enter username as \"([^\"]*)\" and password as \"([^\"]*)\"$")
    public void i_enter_username_as_and_password_as(String username, String password) throws Throwable {
        System.out.println("open login page url");
    }

    @When("^I submit login page$")
    public void i_submit_login_page() throws Throwable {
        System.out.println("open login page url");
    }

    @Then("^I redirect to user home page$")
    public void i_redirect_to_user_home_page() throws Throwable {
        System.out.println("open login page url");
    }

}

My file structure:

enter image description here

And the error:

1 Scenarios (1 failed) 4 Steps (1 failed, 3 skipped) 0m0,225s

java.lang.ExceptionInInitializerError ... Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @378bf509



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source