2017-08-08 12 views
1

私は正常に実行できるEclipseに小さなキュウリJUnitの例があります。その後、私はパッケージ名を改名して、コードで少しでも遊んだ。しかし、今では、と文句を言います: - 私のランナーがどのように見えるステップ定義がキュウリに見つかりませんJava

Feature: Calculator 
    I use Calculator instead of calculating myself 

    @smokeTest 
    Scenario Outline: Add two numbers # src/test/java/cucumber/junit/test/calculatorFeature.feature:17 
    Given I have a calculator 
    When I add 2 and 3 
    Then the result should be 5 

    @smokeTest 
    Scenario Outline: Add two numbers # src/test/java/cucumber/junit/test/calculatorFeature.feature:18 
    Given I have a calculator 
    When I add 4 and 5 
    Then the result should be 9 

    @regressionTest 
    Scenario: Subtract one number from another # src/test/java/cucumber/junit/test/calculatorFeature.feature:21 
    Given I have a calculator 
    When I subtract 2.5 from 7.5 
    Then the result should be 5.0 

3 Scenarios (3 undefined) 
9 Steps (9 undefined) 
0m0,000s 


You can implement missing steps with the snippets below: 

@Given("^I have a calculator$") 
public void i_have_a_calculator() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@When("^I add (\\d+) and (\\d+)$") 
public void i_add_and(int arg1, int arg2) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@Then("^the result should be (\\d+)$") 
public void the_result_should_be(int arg1) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@When("^I subtract (\\d+)\\.(\\d+) from (\\d+)\\.(\\d+)$") 
public void i_subtract_from(int arg1, int arg2, int arg3, int arg4) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@Then("^the result should be (\\d+)\\.(\\d+)$") 
public void the_result_should_be(int arg1, int arg2) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

package cucumber.junit.test; 

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

@RunWith(Cucumber.class) 
@CucumberOptions(

     features = "src/test/java/cucumber/junit/test/calculatorFeature.feature", 
     //This executes all the scenarios tagged as smokeTest and regressionTest 
     format = {"pretty", "html:target/cucumber"}, tags = {"@smokeTest,@regressionTest"}, 
     //This will execute all the scenarios except those tagged as smokeTest 
     // tags = {"[email protected]"}, 
     //glue = {"src/test/java/cucumber/junit/maven/cucumber_jvm/maven"}  
     glue = {"src/test/java/cucumber/junit/test"} 

    ) 
    public class RunCalculatorTest {  

    } 

enter image description here

私は慎重に接着剤へのパスをチェックして、それが正しいです。私も私のプロジェクトを更新し、mvnのクリーンインストールを完了しました。誰かが、なぜそれを定義していないのかを指摘してもらえますか?

+0

'glue'オプションを' glue = {"cucumber.junit.test"} 'や' glue = "cucumber.junit.test" 'に変更してみてください。私はそれがパッケージ名を探していると思います。 –

+0

これが問題でした。スーパークイックアンサーに感謝します。私は答えとしてそれを掲示することができますし、私は答えとしてそれを受け入れます。私はまだパスとパッケージ名をいつ期待しているのだろうか。以前はパスで正常に動作していたためです。 – Ragini

+0

パスでも動作するはずですが、 'glue =" src/test/java/cucumber.junit.test "'を試すことができますか? –

答えて

1

接着剤オプションはおそらくパッケージ名を探しています。このお試しください:このpostをチェック

glue = {"cucumber.junit.test"}

または

glue = "cucumber.junit.test"

を、それは少し古いですが、あなたは時間がない中で始める必要があります。

+0

上記の両方の提案を他の人にも教えてもらいましょう! – Ragini

関連する問題