I did a test automation project using Eclipse + Java + Maven + Cucumber + Selenium
I have the following problem:
As I'm not using git yet, I've exported this project to a .zip file, and in my work I imported it through the 'Existing project into workspace' option.
My project exemplified:
Feature - RequestPayment
Class to call cucumber - PayTestedTest
Class to define the steps - PaySortStepDef
In addition to other page objects in another package
I noticed that when I was changing my step definition class, that same change was not making any effect on the execution of my feature (everything was ok at home, one was reflecting the other normally)
So I deleted my two classes and tried to run the feature again. It performed, even without any class associated with it. Excludes all classes in the project and the feature continues to run successfully. Anyone who knows cucumber knows that the feature only has annotations, does not call any method.
Can anyone explain why this happens? I'm kind of a beginner in java, a friend said that 'it might be that the feature is getting a jar from a path that is set in the project'. But how do I make sure this is it and resolve?
My feature:
// package - bdd_smoke_prod
Feature: Login with Gigya
Scenario Outline: Login
Given I am in the Site
When I log in with "<UserName>" and "<Password>"
Then I will be redirected to the home page logged under my "<Name>"
Examples:
| UserName | Password | Name |
| [email protected] | test123 | Luis |
| [email protected] | erwerewre | Jack |
My runnerclass:
package cucumber_tests;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(plugin= {"pretty", "json:target/"},
features = {"src/main/java/Login.feature"})
public class LoginTest {
}
My definition of steps:
package cucumber_tests;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import pages.HomePage;
import pages.Login;
import tests.BeforeTests;
import utils.DriverMaker;
import utils.DriverMaker.BrowserType;
import static org.junit.Assert.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class LoginStepsDef {
WebDriver driver = new FirefoxDriver();
HomePage dologin = new HomePage(driver);
Login assertlogged = new Login(driver);
@Given("^I am in the Site$")
public void i_am_in_the_Site() throws Throwable {
driver.get("http://www.site.com.br");
driver.manage().window().maximize();
Thread.sleep(2000);
String verificaSite = driver.getCurrentUrl();
assertTrue(verificaSite.contains("www.site.com.br"));
}
@When("^I log in with \"([^\"]*)\" and \"([^\"]*)\"$")
public void i_log_in_with_and(String email, String senha) throws Throwable {
dologin.AcessaLogin().FazLogin(email, senha);
}
@Then("^I will be redirected to the home page logged under my \"([^\"]*)\"$")
public void i_will_be_redirected_to_the_home_page_logged_under_my(String username) throws Throwable {
assertlogged.ValidaAcesso(username);
}
}
Note that this class is the only place in the project that can reproduce these steps (access the site, log in, check if the name is correct). If I delete this class and try to run the feature, I can do all of this normally, as if the feature was fetching this code from ... beyond?
Thank you.