0

私は現在、後で Hudson テスト サーバーで実行される Fest Junit テスト ケースを作成しています。テストケースが失敗した場合は、デスクトップのスクリーンショットを撮ってもらいたいです。これを設定する方法に関するチュートリアルがあるこの URL を見つけました: http://fest.codehaus.org/Taking+Screenshots+of+JUnit+Test+Failuresしかし、テストはローカルで実行されません。

これは、私が実行しようとしているJavaコードのコピーです。

@RunWith(GUITestRunner.class)
public class AddingNewUserTest extends FestTest {
    @Before
    public void setup(){
       super.setup(constants.users.name);
    }

    @After
    public void cleanup(){super.shutDown();

    }

    @GUITest
    public void testAddingNewUser() throws InterruptedException{
      //java code
}

そして、実行しようとしている JUnit Ant タスク:

<target name="run.tests" description="Runs all the junit tests.">
    <echo message="Run the tests"/>
    <taskdef resource="festjunittasks" classpathref="classpath" />
    <junit printsummary="true" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="yes">
         <classpath refid="classpath" />
          <formatter classname="org.fest.swing.junit.ant.ScreenshotOnFailureResultFormatter" extension=".xml" />

          <batchtest todir="${test.output.reports.test.dir}" unless="testcase" fork="true">
                 <fileset dir="${output.mainclasses.dir}" includes="**/AddingNewUserTest.class" excludes="**/FestTest.class,**/DefaultsTest.class"/>
           </batchtest>
        </junit>

        <festreport todir="${test.output.reports.dir}">
              <classpath refid="classpath" />
              <fileset dir="${test.output.reports.test.dir}">
                     <include name="TEST-*.xml" />
               </fileset>
               <report format="frames" todir="${test.output.reports.dir}/html" />
         </festreport>

        <antcall target="kill.server"/>

</target>

どんな助けでも素晴らしいでしょう。

ここに画像の説明を入力

レポートで Junit によってスローされたエラーのスクリーン ショット

4

1 に答える 1

0

これは、インターネット上でいくつかのソースコードに出くわした後に見つけた簡単な解決策です (誰かがこのスレッドに出くわした場合): Java コード:

@GUITest
public void testAddingNewUser() throws InterruptedException{
      //java code

する必要があった

@Test
@GUITest
public void testAddingNewUser() throws InterruptedException{
      //java code

それ以外は正しかったようです

于 2014-07-23T12:21:44.037 に答える