0

我目前正在编写 Fest Junit 测试用例,稍后将在 Hudson 测试服务器上运行。如果任何测试用例失败,我想让他们拍摄桌面屏幕截图。我发现这个网址有一个关于如何设置它的教程: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 回答