gradle failed to find my test. already switching between JUnit too and its still not fix it, and it still give same error as its not found. i tried everything to find a way to look for solution but no luck. even asking my mentor still doesnt find any solution. asking chatGPT also no luck, struggle with this not found problem enter image description here
my feature in src/test/resources
Feature: Login
Scenario Login with valid username & password
Given user is on login page
When user input email text box with "standard_user"
And user input password on text box "secret_sauce"
And user click Login button
Then user will redirect to homepage
theStepDef it self (i start again from scratch because it got deleted by accident) in com/nadif/stepdef
package com.nadif.stepdef;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
public class MyStepdefs {
@Given("user is on login page")
public void userIsOnLoginPage() {
}
@When("user input email text box with {string}")
public void userInputEmailTextBoxWith(String username) {
}
@And("user input password on text box {string}")
public void userInputPasswordOnTextBox(String password) {
}
@And("user click Login button")
public void userClickLoginButton() {
}
@Then("user will redirect to homepage")
public void userWillRedirectToHomepage() {
}
}
these are the CucumberTest Code
package com.nadif;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "com.nadif.stepdef",
features = "src/test/resources",
plugin = {"pretty"}
)
public class CucumberTest {
}
these are the error logs that show up in terminal
No matching tests found in any candidate test task.
Requested tests:
Test pattern com.nadif.CucumberTest in task :test
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 3s
4 actionable tasks: 3 executed, 1 up-to-date
these are my dependencies and test
dependencies {
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.27.0'
testImplementation("io.github.bonigarcia:webdrivermanager:5.9.0")
testImplementation 'io.cucumber:cucumber-java:7.20.1'
testImplementation 'io.cucumber:cucumber-spring:7.20.0'
testImplementation 'io.cucumber:cucumber-junit:7.20.1'
testImplementation 'junit:junit:4.13.2'
}
test {
useJUnit()
include '**/CucumberTest*'
}
In your feature file, you are missing a colon on the Scenario keyword. Try it with Scenario: to have it invoke your step definition class.