Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 编写参数化测试失败,原因是:检索testcase的参数时出错:导致参数化字段的值无效_Actionscript 3_Apache Flex_Flex4.5_Flexunit4 - Fatal编程技术网

Actionscript 3 编写参数化测试失败,原因是:检索testcase的参数时出错:导致参数化字段的值无效

Actionscript 3 编写参数化测试失败,原因是:检索testcase的参数时出错:导致参数化字段的值无效,actionscript-3,apache-flex,flex4.5,flexunit4,Actionscript 3,Apache Flex,Flex4.5,Flexunit4,我有一些单元测试需要非常大的字符串作为测试数据。我不想在测试本身中声明HTML字符串,因为这会模糊实际的测试。相反,我希望为每个测试从外部资源加载这些字符串 虽然我没有用不同的数据集运行相同的测试,但参数化测试看起来是一个可行的解决方案;但是,我很难让下面的示例工作 注意:此代码基于 运行此测试时,我收到以下错误消息: 错误:检索testcase的参数时出错: 导致参数化字段htmlContent的值无效:null 关于这个问题的解决方案有什么想法吗?我找到的一个解决方案是在课堂上用理论运行器运

我有一些单元测试需要非常大的字符串作为测试数据。我不想在测试本身中声明HTML字符串,因为这会模糊实际的测试。相反,我希望为每个测试从外部资源加载这些字符串

虽然我没有用不同的数据集运行相同的测试,但参数化测试看起来是一个可行的解决方案;但是,我很难让下面的示例工作

注意:此代码基于

运行此测试时,我收到以下错误消息:

错误:检索testcase的参数时出错: 导致参数化字段htmlContent的值无效:null


关于这个问题的解决方案有什么想法吗?

我找到的一个解决方案是在课堂上用
理论运行器运行测试,如下所示

package flexUnitTests
{
    import helpers.HTMLDataHelper;

    import org.flexunit.experimental.theories.Theories;
    import org.flexunit.runners.Parameterized;
    import org.hamcrest.assertThat;
    import org.hamcrest.object.equalTo;
    import org.hamcrest.text.containsString;

    [RunWith("org.flexunit.experimental.theories.Theories")]
    public class SimpleTestCase
    {
        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: Expected: a string containing "head"
but: was "this is some text"
虽然这确实“解决”了我遇到的问题,但我认为在消息清晰度方面的权衡不值得从外部源加载数据

Error: Expected: a string containing "head"
but: was "this is some text"