groovy – 使用参数化Junit测试中的命令行参数或系统属性?
发布时间:2020-12-14 16:23:56 所属栏目:大数据 来源:网络整理
导读:我使用此方法来设置参数化数据: @Parameterized.Parameterspublic static CollectionObject[] getStories() { CollectionObject[] allStories = new ArrayListObject[]() new File(SPEC_DIRECTORY).eachFileRecurse(FileType.FILES) { file - if (file.getN
我使用此方法来设置参数化数据:
@Parameterized.Parameters public static Collection<Object[]> getStories() { Collection<Object[]> allStories = new ArrayList<Object[]>() new File(SPEC_DIRECTORY).eachFileRecurse(FileType.FILES) { file -> if (file.getName().endsWith('.story')) { Object[] args = [file.getName(),file] allStories << args } } return allStories } 我通过gradle测试使用gradle调用主测试,但我似乎无法看到系统属性. 如果我使用调用gradle -Dfile = test.story,则System.getProperty(‘file’)是未定义的.如何将参数传递给此参数化数据构建器? 解决方法
Gradle在单独的JVM中运行所有测试.您必须配置测试任务:
test { systemProperty "file","test.story" } 有关更多信息,请参阅Gradle DSL reference. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |