複数の XML ドキュメントに対して一連のテストを実行しようとしています。構成ファイルから製品 ID のリストを取得し、すべてのドキュメントに対して同じ一連のテストを実行したいと考えています。ただし、これを行うと、テスト統計の最終的な要約を 1 つも取得できません。
サンプルコードは次のとおりです。
import org.scalatest._
import org.scalatest.matchers.ShouldMatchers._
import scala.xml._
import dispatch._
class xyzSpec(webcli: Http, productId: String) extends FeatureSpec with GivenWhenThen with ShouldMatchers {
feature("We get up to date xyz data from xyzsystem with correct blahblah info") {
info("As a programmer")
info("I want to lookup a product in xyzsystem")
info("So that I can check the date updated and blahblah info")
scenario("We have an up to date product with correct blahblah info") {
given("Product " + productId)
// code to get product XML doc
when("when we request the db record")
// code to get crosscheck data from SQL db
then("we can get the product record")
// code to compare date updated
and("date updated in the XML matches the SQL db")
}
}
}
val h = new Http
val TestConfXml = h(qaz <> identity)
ProdIdsXml \\ "product" foreach { (product) =>
val productId = (product \ "@id").text
new xyzSpec(h, productId).execute(stats=true)
}
最後から 3 行目foreach
には、テスト ランナーを複数回呼び出す a があります。テスト オブジェクトをネストできる (またはテスト クラスをテストする) ことはわかっていますが、テスト クラス コンストラクターがパラメーターを受け取るときに、実行時にこれを動的に行う方法がわかりません。
私は何が欠けていますか?