2014-09-05 5 views
0

동일한 테스트를 여러 번 실행하여 기능을 확인할 수 있습니까? 나는 2 개의 다른 사용자를 위해이 시나리오를 실행하려는다른 사용자 역할을 사용하여 동일한 BDD 기능을 여러 번 실행하는 방법

Feature: End to end tests 

    I want an End to End test pack 
    As Super user and Admin user 
    So that I can ensure that the integrated components of the application function as expected 

    Background: 
      Given I have the login Page 
      When I login to application 
      Then the list is displayed 

    @javascript 
    Scenario: To verify the functionality on the Dashboard   
      When I navigate to the Dashboard Page 
      Then the Dashboard Page is displayed 

:

여기 내 기능 파일입니다. 여러 사용자/역할을 사용하여 동일한 기능을 실행할 수있는 방법이 있습니까? 예, 당신이 할 수있는

public function iLoginToApplication() { 
$page = $this->getSession()->getPage(); 
$page->find('css', '#username')->setValue("admin"); 
$page->find('css', '#password')->setValue("Password"); 
$signInButton->press(); 
} 
+0

19 개 질문을 모두 거쳐 13 세 이상의 직장 경험을 보완 할 때 도움이 될만한 사람들도 있습니다. 커뮤니티는 당신이 알고있는 시간을 보낸다. –

+1

나는 어디에서 왔는지 완전히 이해하고 감사한다. 그리고 나는 관련성있는 것을 받아 들였고 그것에 대해 논평했다. 좀 더 구체적이 될 수 있습니까 –

답변

1

:

는 내가 하룻밤

아래의 상황에 맞는 파일을 참조하십시오 실행해야 할 2 또는 3 개의 다른 사용자를 사용하여 실행해야하는 여러 가지 다른 기능의 파일이 있습니다. Feature: … 바로 아래 부분은 기능적 관점에서 볼 때 거의 쓸모가 없으며 문서로 사용됩니다. AFIAK 당신이 그것을 삭제하거나 원하는 것을 쓸 수 있습니다, 당신의 테스트는 정확히 동일하게 실행됩니다.

당신이 찾고있는 것은 scenario outlines입니다. 몇 가지 시나리오를 업데이트하고 각 사용자를 수동으로 지정해야합니다 (Examples).

Feature: End to end tests 

    I want an End to End test pack 
    As Super user and Admin user 
    So that I can ensure that the integrated components of the application function as expected 

    Background: 
     Given I have the login Page 

    @javascript 
    Scenario Outline: To verify the functionality on the Dashboard   
     When I login to application as "<username>" with "<password>" 
     Then the list is displayed 
     When I navigate to the Dashboard Page 
     Then the Dashboard Page is displayed 

    Examples: 
     | username | password | 
     | super | qwerty | 
     | admin | qwerty | 

/** 
* @When /^I login to application$/ 
* @When /^I login to application as "(.+)" with "(.+)"$/ 
*/ 
public function iLoginToApplication($username = null, $password = null) { 
    $page = $this->getSession()->getPage(); 
    $page->find('css', '#username')->setValue(isset($username) ? $username : 'admin'); 
    $page->find('css', '#password')->setValue(isset($password) ? $password : 'Password'); 
    $signInButton->press(); 
} 

또 다른 방법은 세계적인 규모에이를 구성하는 것입니다 전에 스위트를 실행하는, 예를 들어, 당신이 Behat을 실행하고 다른 구성으로 모든 것을 여러 번 실행할 때 PHP에 사용자 이름과 환경 변수를 전달합니다. 위의 해법은 직관적이지 못하기 때문에 Behat 방식을 사용하는 것이 더 나을 것입니다.

+0

답장을 보내 주셔서 감사합니다. 우리 환경이 돌아가고 돌아갈 때이 해결책을 시도 할 것입니다. –

+0

그것이 일을하는지 알려주세요. –

+0

안녕하세요,이 솔루션을 사용하려고합니다. 그러나 문제는 내 컨텍스트 파일에서 사용하고 있습니다. 내 컨텍스트 파일에 인수로 전달할 수 있습니다. 문맥에 대한 위의 설명을 참조하십시오. –