0

この記事のサンプルコードを試しています

私はコードの実際の例を持っていますが、記事の著者は 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 属性に渡す方法を知っている人はいますか?

4

1 に答える 1

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>
于 2012-09-18T17:00:55.237 に答える