2011-04-11 5 views
0

뭔가 :오이 시나리오를 기능으로 사용할 수 있습니까? 같은

Scenario: Create a Test Category 
    Given I am on the regression test test cases page 
    When I follow "New Category" 
    And I fill in "Name" with "Test Category" 
    And I press "Add Category" 
    Then I should see "Test Category" within ".test-categories-list" 

Scenario: Add a Test Case 
    Given I "Create a Test Category" 

나는 다음 테스트 카테고리를 만드는 테스트 케이스를 만드는 "단계별"절차를 싶습니다. 이 작업을 수행하지 않고도 "테스트 카테고리를 만들었습니다"라는 질문을 받고 공장을 운영하고 있습니까?

답변

0

테스트 코드를 프로덕션 코드처럼 취급하고 클래스에 캡슐화해야하는 상황입니다. 그런 다음 필요할 때마다 쉽게 다시 사용할 수 있습니다.

class TestCategory 
    def create(values) 
    follow_new_category 
    fill_in_name 
    press_add 
    end 

    def follow_new_category 
    end 

    def fill_in_name 
    end 

    def press_add 
    end 
end 

당신은 다음 단계에서 이러한 메서드를 호출 할 수 있습니다 :

When /I fill in "Name" with "(.*)"/ do |category_name| 
    TestCategory.new.fill_in_name(category_name) 
end 

(당신은 다른 방법으로 TestCategory 클래스의 라이프 사이클을 관리 할 수 ​​있습니다 그림을 위해서

매번 새로운 인스턴스를 생성하는 대신 ...)

그러나 단계는 좋은 연습으로 간주되지 않습니다.

Scenario: Create a Test Category 
    Given I am on the regression test test cases page 
    When I add a test category 
    Then I should see "Test Category" within ".test-categories-list" 

이 그럼 당신은 너무 많은 소문자 방법으로 지원 코드를 분해 할 필요가 없습니다 : 그것은 이런 식으로 뭔가를 말했다 경우는 더 좋은 것이다.

+0

그래서 어떻게하면 오이의 TestCategory 클래스에 메서드를 만들 수 있습니까? – corroded

+0

대답을 업데이트했습니다 .. –

+0

"주어진 시나리오 : 테스트 범주 만들기"가 실행되었습니다 "? – corroded

관련 문제