2014-03-25 3 views
11

내가 아래있는 기능 파일이있는 정의. 내가 대신오이 시나리오의 개요 및 예

예제 섹션에서 모든 사용자 이름이나 암호 또는 제목 값을 매핑 할 수있는

일반적인 단계 정의를 가질 수 있습니다.

즉 대신 당신은 생산 것이 형식

Scenario Outline: Create ABC 

    Given I open the application 
    When I enter username as "<username>" 
    And I enter password as "<password>" 
    Then I enter title as "<title>" 
    And press submit 

를 사용해야합니다

@When("^I enter username as Rob$") 
public void I_enter_username_as_Rob() throws Throwable { 
    // Express the Regexp above with the code you wish you had 
    throw new PendingException(); 
} 

내가

@When("^I enter username as <username>$") 
public void I_enter_username_as_username(<something to use the value passed>) throws Throwable { 
    // Express the Regexp above with the code you wish you had 
    throw new PendingException(); 
} 
+0

어떻게 이런 일이있을 수 있습니까? 그것은 오래된 오이 플러그인이어야하며, nowdays outline은 잘 지원되며, 의 경우 하나의 일반적인 단계 함수 만 생성합니다. "" – user1559625

+0

로 변경하지 않아도됩니다. JUnit을 통해 실행될 때 CucumberJVM 1.2.5에서 계속 발생합니다. 따라서 따옴표를 사용하십시오. :-) –

답변

23

를 입력 할 수 있습니다 말하는

@When("^I enter username as \"([^\"]*)\"$") 
public void I_enter_username_as(String arg1) throws Throwable { 
    // Express the Regexp above with the code you wish you had 
    throw new PendingException(); 
} 

arg1 이제 사용자 이름/값이 전달됩니다.

+0

고마워요! – trial999

+2

감사합니다! 나는 또한 "([^ \"] *) \ "가 정규식이고 따옴표로 시작하는 문자열을 찾고 다른 문자가 정의되지 않은 수로 끝나고 있음을 설명하기를 원합니다 (별표 *는이를 제공합니다). 그래서 우리가 ""을 보면 인용 부호로 시작한다는 것을 알 수 있습니다. 누군가에게 도움이 되길 바랍니다. – hipokito

+1

은 @hipokito에 의해 ** 대안 **으로 이렇게 명확 해졌습니다.'@When ("^ 사용자 이름을 다음과 같이 입력합니다. \ "(. +) \"$ ")' – DaddyMoe

0

오이는 콘솔에서 자동으로 누락 된 단계를 제공합니다. 마른 실행을하면 콘솔에 누락 된 단계가 표시됩니다.

@RunWith(Cucumber.class) 
@CucumberOptions(plugin = { "pretty" }, features = { "<path_to_feature>" }, 
    glue = { "<optional_steps_location_java_file>" }, dryRun = true, 
    tags = { "<optional_NOT_req_for_now>" }) 
public class RunMyCucumberTest { 

} 

See for more Cucumber options

관련 문제