如何生成PDE测试类列表?

时间:2012-08-30 07:15:17

标签: eclipse ant junit

我正在尝试使用此article

的示例代码

我有一个代码的工作示例,但该文章的作者谈到了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属性?

1 个答案:

答案 0 :(得分:0)

我解决了我的问题。这是我的解决方案。我将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>
相关问题