0

easybWebサイトのeasybシナリオの例を次に示します。

before "start selenium", {
 given "selenium is up and running", {
  selenium = new DefaultSelenium("localhost",
    4444, "*firefox", "http://acme.racing.net/greport")
  selenium.start()
 }
}

scenario "a valid person has been entered", {

 when "filling out the person form with a first and last name", {
  selenium.open("http://acme.racing.net/greport/personracereport.html")
  selenium.type("fname", "Britney")
  selenium.type("lname", "Smith")
 }

 and "the submit link has been clicked", {
  selenium.click("submit")
 }

 then "the report should have a list of races for that person", {
  selenium.waitForPageToLoad("5000")
  values = ["Mclean 1/2 Marathon", "Reston 5K", "Herndon 10K", "Leesburg 10K"]
  for(i in 0..<values.size()){
    selenium.getText("//table//tr[${(i+3)}]/td").shouldBeEqualTo values[i]
  }
 }
}

after "stop selenium" , {
 then "selenium should be shutdown", {
  selenium.stop()
 }
}

Groovyを英語から分離して、次のようなものを提示することは可能ですか?

scenario "a valid person has been entered"
  given "the website is running"
  when "filling out the person form with a first and last name"
  and "the submit link has been clicked"
  then "the report should have a list of races for that person"

そうすれば、私のPHBは中かっことGroovyによってすべてが混乱することはありません。

4

3 に答える 3

1

おそらく正当な努力ではないでしょう。それでも、コードクロージャを外部で簡単に定義できます。「人間が読める」部分は次のようになります。

scenario "a valid person has been entered", {
    when "filling out the person form with a first and last name", 
        fillOutPersonForm
    and "the submit link has been clicked", 
        clickSubmitLink
    then "the report should have a list of races for that person", 
        checkRacesList
}

クロージャー名が説明的で自己文書化されていることを確認してください。実際、完全に書かれた説明よりも読みやすいと思います...

クロージャの定義は次のように定義されています。

def fillOutPersonForm = {
    selenium.open("http://acme.racing.net/greport/personracereport.html")
    selenium.type("fname", "Britney")
    selenium.type("lname", "Smith")
}
于 2010-11-19T14:46:37.507 に答える
1

実際、これはすでにANT統合によるeasybの機能だと思います。「ストーリー印刷」セクションのhttp://www.easyb.org/running.htmlを確認してください。

于 2011-01-07T13:48:24.807 に答える
1

SJGの 回答の拡張として、これをプログラムで実行するためのコードスニペットがあります。

http://www.easyb.org/running.htmlのeasybドキュメントでは、コマンドラインから「ストーリー」テキストビューを作成する方法についてのみ説明しています。Groovyコードでこれを行うのは簡単な作業です...

import org.easyb.BehaviorRunner

def params=["C:/temp/teststory.story", "-txtstory", "C:/temp/testoutput.html"] as String[]
BehaviorRunner.main(params)

2番目のパラメーターとして-htmlまたは-xmlを使用して、HTMLレポートとXMLレポートに同様のアプローチを使用できます。

テストを実行せずにレポートだけを作成するために必要なパラメーターがまだわかりません。これは可能であるはずです。問題165の修正を参照してください。これをストーリーの最後の部分として追加すると、「ユーザー」ドキュメントが常に作成されます。上記のスニペットではテストが実行されるため、に含めることはできません。同じストーリーファイルを使用しないと、再帰ループに入ります。

于 2011-01-24T15:57:45.880 に答える