2017-07-27 11 views
0

私はCucumberRunnerを実行したときに開始しないキュウリとFluentleniumプロジェクトを持っています。それは単にすべてのテストをスキップします。私はインターネット上で解決策を見つけようとしましたが、これまで問題を理解していませんでした。ちょっとした助けがよかったです。Fluentleniumとキュウリの試験が開始されていません

public class LoginPageSteps extends BaseTest { 

public LoginPageSteps() throws Exception { 
    super(); 
} 

@Page 
LoginPage loginPage; 


@Given("^I am on login page$") 
public void goToLoginPage(){ 
    goTo(loginPage); 
} 

@When("^I enter username as '(.*?)'$") 
public void enterUsername(String username) { 
    waitAndFill(loginPage.username, username); 
} 

@And("^I enter password as '(.*?)'$") 
public void enterPassword(String password) { 

    waitAndFill(loginPage.password, password); 
    waitUntilCliclableAndClick(loginPage.loginButton); 

} 

@Then("^Login should be succesfull$") 
public void checkLoginStatus() { 
    assertTrue(getDriver().getCurrentUrl().contains("login_attempt=1")); 

} 
} 

これは私のBaseTest.classです::これは

は私の手順です

public class BaseTest extends FluentCucumberTest { 

@Page 
AccountPage accountPage; 


@Before 
public void before(Scenario scenario) { 
    super.before(scenario); 
} 

@After 
public void after(Scenario scenario) { 
    super.after(scenario); 
} 

@Override 
public WebDriver newWebDriver() { 

    System.setProperty("webdriver.gecko.driver", "../cucumber-test/src/test/resources/geckodriver.exe"); 
    FirefoxDriver driver = new FirefoxDriver(); 

    return driver; 
} 

public void waitUntilCliclableAndClick(FluentWebElement element) { 
    await().atMost(5, TimeUnit.SECONDS).until(element).clickable(); 
    element.click(); 
} 

public void waitAndFill(FluentWebElement element, String data) { 
    await().atMost(5, TimeUnit.SECONDS).until(element).displayed(); 
    element.fill().with(data); 
} 



} 

そして、これは私の機能ファイルです:

Feature: valid-login 

Scenario: 
    Given I am on login page 
    When I enter username as "myusername" 
    And I enter password as "mypassword" 
    Then Login should be succesfull 

そして、これはランナーです:

@RunWith(Cucumber.class) 
@CucumberOptions(features={"src/test/resources/features"}) 
public class CucumberRunner { 

} 

答えて

0

これはあなたに役立つexample projectが見つかりました。

私はこのサンプルプロジェクトをクローン/実行しましたが、キュウリバージョンは古いので更新が必要です。

は、ここで私は、プロジェクトの作業をするために何をやったかです:

1.2.5などpom.xmlで最新バージョンにjunithtmlunit-driverfluentlenium-cucumber3.3.0fluentlenium-assertjcucumber-corecucumber-junitcucumber-javacucumber-picocontainerを更新しました。

ステップファイルは、次のようになります。

import cucumber.api.Scenario; 
import cucumber.api.java.After; 
import cucumber.api.java.Before; 
import cucumber.api.java.en.Given; 
import org.fluentlenium.adapter.cucumber.FluentCucumberTest; 
import org.openqa.selenium.htmlunit.HtmlUnitDriver; 
import static org.assertj.core.api.Assertions.assertThat; 

import java.util.concurrent.TimeUnit; 

public class BasicStep extends FluentCucumberTest { 

    @Before 
    public void before(Scenario scenario) { 

    } 

    @Override 
    public WebDriver newWebDriver() { 
     System.setProperty("webdriver.gecko.driver", "path/to/geckodriver"); 
     WebDriver driver = new FirefoxDriver(); 
     return driver; 
    } 

    @Given("I open Google") 
    public void iOpenGoogle() { 
     this.initFluent(new newWebDriver()); 
     goTo("http://google.com"); 

     await().atMost(5, TimeUnit.SECONDS); 
     assertThat(window().title()).contains("Google"); 
    } 

    @After 
    public void after(Scenario scenario){ 
     super.after(scenario); 
    } 
    } 

とテストファイル:

import cucumber.api.CucumberOptions; 
import cucumber.api.junit.Cucumber; 
import org.junit.runner.RunWith; 

@RunWith(Cucumber.class) 
@CucumberOptions(features = "src/test/resources/toto") 

public class BasicTest { 

} 

新しいテスト結果:

enter image description here

は、あなたはそれが働いてもらう願っています!

+0

どのキュウリのバージョンを使用しましたか? –

+0

サンプルプロジェクトのキュウリの古いバージョンと思われます。サンプルプロジェクトを調査/更新し、あなたに戻ってきます。 –

+0

あなたのシナリオを試してみましたが、動作しますが、実行時にnullなので@BeforeでgetDriver()を呼び出すことができないため、私の場合は動作しません。 newWebDriver()メソッドをオーバーライドして、前回の代わりにドライバを設定したいのは、1回だけ実行したいからです。 Beforeを呼び出すと、他のテストが実行されたときにドライバが再び初期化されます。 –

1

あなたのキュウリのランナーはあなたがMavenを使ってビルドする場合、これは問題になることがありCucumberRunner

と呼ばれています。 MavenのSurefireのテストランナーは、XXXXTestまたはTestXXXXという名前のクラスを検索します。ランナークラスが見つかりません。

キュウリランナーの名前をCucumberRunnerTestに変更し、問題が解決するかどうか確認してください。

関連する問題