meine Funktion in src/test/resources
Code: Select all
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
Code: Select all
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() {
}
}
Code: Select all
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 {
}
Code: Select all
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
Code: Select all
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*'
}