私はGWT
の仕様を全面的にサポートしようとしていますが、official documentationの例はちょっと単純です。 SOでの検索複雑なオブジェクトを指定してGiven/Then/Specを書くとき
私はこの質問が見つかりました:
をしかし、それは(3年)古すぎると私はspecs2
でGWT
を行う方法が変更されたと思います。
class FlowCollectorSpec extends Specification
with GWT
with StandardRegexStepParsers { def is = s2"""
Given a API route to get flows ${apiCaller.start}
Given an access to the API URL: http://192.168.56.102:8080/stats/flow/
When getting flow stats for a switch with id: 1
Then status code should be: 200 ${apiCaller.end}
"""
val anAPIUri = readAs(".*: (.*)$").and((s: String) => s)
val apiCaller =
Scenario("apiCaller").
given(aString).
given(anInt).
when(anAPIUri) {case url :: dpid :: _ => FlowCollector.getSwitchFlows(dpid)}.
andThen(anInt) {case expected :: actual :: _ => actual.code must_== expected}
}
がどのように私は考える文の複雑なオブジェクトを指定することができます。
は、これまでのところ、私はこの簡単なテストがありますか?このような何か:
Given a Json response: ${jsonResponse}
解決策が優れているかもしれません。私はそれを試してみるだろう。 'FlowCollector'オブジェクトと' FlowResult'の目的は何ですか? – elbaulp
元のコードをコンパイルするために 'FlowCollector'を追加し、(コードをコンパイルするために)' .code'メソッドを持つものを再現するために 'FlowResult'を追加しました。 – Eric
Ahh、ありがとう、ありがとう。テストをどのように構造化すれば良いと思いますか? – elbaulp