【问题标题】:Taking Screenshot of failed Fest JUnit test拍摄失败的 Fest JUnit 测试的屏幕截图
【发布时间】:2014-07-22 19:13:17
【问题描述】:

我目前正在编写 Fest Junit 测试用例,稍后将在 Hudson 测试服务器上运行。如果任何测试用例失败,我想让他们拍摄桌面屏幕截图。我发现这个 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 在报告中抛出的错误截图

【问题讨论】:

    标签: ant junit fest


    【解决方案1】:

    这是我在互联网上偶然发现一些源代码后发现的一个快速解决方案(如果有人偶然发现这个线程): java代码:

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

    需要

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

    其他一切似乎都是正确的

    【讨论】:

      猜你喜欢
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 2014-01-12
      • 2011-01-08
      相关资源
      最近更新 更多