我有幾個單元測試需要測試數據的字符串非常大。我不想在測試中聲明HTML字符串,因爲這會掩蓋實際的測試。相反,我想從每個測試的外部資源加載這些字符串。寫入參數化測試失敗,出現以下情況:檢索測試用例參數時發生錯誤:導致參數化字段的值無效
儘管我沒有對不同的數據集進行相同的測試,但參數化測試看起來是一個可行的解決方案;然而,我很難得到下面的例子工作。
注意:此代碼基於TestNG example。
package flexUnitTests
{
import helpers.HTMLDataHelper;
import org.flexunit.runners.Parameterized;
import org.hamcrest.assertThat;
import org.hamcrest.text.containsString;
[RunWith("org.flexunit.runners.Parameterized")]
public class SimpleTestCase
{
private var parameterized:Parameterized;
public static var dataLoader:HTMLDataHelper = new HTMLDataHelper("data/layer.html");
[DataPoint(loader="dataLoader")]
public static var htmlContent:String;
[Test(dataprovider="htmlContent", description="Tests something.")]
public function mustPassThisSimpleTest(htmlContentParam:String):void
{
assertThat(htmlContentParam, containsString("head"));
}
}
}
當我運行這個測試我收到以下錯誤信息:
Error: There was an error retrieving the parameters for the testcase: cause invalid value for parameterized field htmlContent: null
任何想法,以什麼可能是解決這個問題可能是什麼?