我正在实验这个文章的示例代码
我有一个代码的工作示例,但是本文的作者提到了PDE测试类列表:
PDE测试运行程序将在PDE测试运行中运行的测试类的逗号分隔列表作为参数。在示例代码中,要运行的单个测试类的名称是硬编码的,即phonebookexample.dialogs.PhoneBookEntryEditorDialogTest,但是可以很容易地自动生成PDE测试类的列表。
他的示例中的代码在-classnames属性中使用了一个测试类:
<target name="run_pde_tests">
<property name="test.classes.list" value="phonebookexample.dialogs.PhoneBookEntryEditorDialogTest"/>
<mkdir dir="${test.reports.dir}/output/ws"/>
<java dir="${plugin.dir}" classname="org.eclipse.equinox.launcher.Main" fork="yes" classpathref="equinox.launcher.class.path">
<arg line="-application org.eclipse.pde.junit.runtime.uitestapplication -data ${test.reports.dir}/output/ws -dev bin -clean -port ${pde.test.port} -testpluginname PhoneBookExample -classnames ${test.classes.list}"/>
</java>
</target>有没有人知道我如何用ant生成一个测试类列表,并将这个列表交给org.eclipse.pde.junit.runtime.uitestapplication的-classnames属性?
发布于 2012-09-18 17:00:55
我解决了我的问题。这是我的解决方案。我将test.dir.totest指向包含插件的目录。文件集是用java文件创建的。此集合被转换为一个空格分隔的列表,一个分配给ant属性的列表。在java任务中使用此属性来运行测试。
<!-- point to a directory with java files to PDE unit test -->
<property name="test.dir.totest" location="/pathtomytestclasses/testplugin"/>
<!-- Include all java files in the given directory and sub directories -->
<path id="semantics.classpath">
<fileset dir="${test.dir.totest}" id="test.files">
<include name="**/*.java"/>
</fileset>
</path>
<!-- this will convert the java files to a space separated list -->
<!-- ant place it in a javafiles ant property -->
<!-- This property is passed in the arg line of the ant java task -->
<!-- to run the PDE tests -->
<pathconvert pathsep=" " property="javafiles">
<path refid="semantics.classpath"/>
<!-- this regex will create 3 groups -->
<!-- group 1 is the path -->
<!-- group 2 is the filename withouth the .java extension -->
<!-- group 3 is the file extension -->
<mapper type="regexp" from="^(.+)/([^/]+)$?.java" to="my.package.name.\2"/>
</pathconvert>https://stackoverflow.com/questions/12191732
复制相似问题