2012-10-29 5 views
3

이미지 로테이터/사이클이 작동하는지 테스트하기 위해 Cucumber/Watir 테스트 작업. 내 전략은 css 클래스에 의해 회전 자의 활성 이미지를 잡아서 변수에 덤프하는 것입니다. 그런 다음 다음 버튼을 클릭하고 css 클래스에 의해 로테이터에서 현재 이미지 (새 이미지이어야 함)를 잡고 두 번째 변수로 덤프합니다. 그렇다면 img_rot_1! = img_rot_2을 말하고 테스트가 true 또는 false를 반환하도록 할 수 있어야합니다. 이것은 내가 곤경에 빠졌던 부분이다.Watir 동등성 테스트

저는 루비를 처음 접했기 때문에 간단한 것을 놓치기도합니다. 여기 테스트가 있습니다. !

require 'step_definition/setup' 

test_setup = Wsetup.new 'http://loginurl', 'uname', 'pass' # browser object created here as # test_setup.b 
img_rot_1 = String.new 
img_rot_2 = String.new 

When /^I click the next image button$/ do 
    test_setup.do_login 
    test_setup.b.goto('http://psu.dev1.fayze2.com/node/56') 
    img_rot_1 = test_setup.b.li(:class => 'flex-active-slide').img.src 
    test_setup.b.link(:class => 'flex-next').click 
end 

Then /^the rotator should move to the next image$/ do 
    img_rot_2 = test_setup.b.li(:class => 'flex-active-slide').img.src 
    img_rot_1 != img_rot_2 
end 

img_rot_1 = img_rot_2 및 img_rot_1 == img_rot_2 모두 패스 - 내가 무엇을 놓치고?

답변

0

Then 단계가 실패하면 false로 평가되는 진술뿐만 아니라 실패한 명제가 필요합니다.

당신이 RSpec에 기대를 사용하는 가정, 당신은 같은 것을 원하는 것 :

img_rot_1.should_not eq(img_rot_2) 
1

을 나는 당신이 다른 단계에서 한 단계에서 생성되는 변수에 액세스하려면 인스턴스 변수를 사용하는 것 같아요.

뭔가 같은 :

When /^I click the next image button$/ do 
    # more code here 
    @img_rot_1 = test_setup.b.li(:class => 'flex-active-slide').img.src 
end 

Then /^the rotator should move to the next image$/ do 
    img_rot_2 = test_setup.b.li(:class => 'flex-active-slide').img.src 
    @img_rot_1.should_not == img_rot_2 
end