Package org.fest.swing.junit.ant
package org.fest.swing.junit.ant
Support for embedding screenshots of failed GUI tests in a JUnit HTML report (created with Ant.)
To embed screenshots of failed GUI tests in the HTML JUnit reports, please follow the these steps:
-
Mark GUI tests with the annotation
org.fest.swing.annotation.GUITest
-
Add a definition of the Ant task
festreport
(provided by this module) -
Use the formatter
inside theScreenshotOnFailureResultFormatter
junit
Ant task -
Use the Ant task
festreport
instead ofjunitreport
, and specify in its classpath where the fest-swing-junit jar is
Here is an example:
<target name="test" depends="compile">
<taskdef resource="festjunittasks" classpathref="lib.classpath" />
<junit forkmode="perBatch" printsummary="yes" haltonfailure="no" haltonerror="no">
<classpath refid="lib.classpath" />
<classpath location="${target.test.classes.dir}" />
<classpath location="${target.classes.dir}" />
<formatter classname="org.fest.swing.junit.ant.ScreenshotOnFailureResultFormatter" extension=".xml" />
<batchtest fork="yes" todir="${target.junit.results.dir}">
<fileset dir="${target.test.classes.dir}" includes="**/*Test*.class" />
</batchtest>
</junit>
<festreport todir="${target.junit.report.dir}">
<classpath refid="lib.classpath" />
<fileset dir="${target.junit.results.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${target.junit.report.dir}/html" />
</festreport>
</target>
-
ClassesClassDescriptionUnderstands common constants used in this package.Understands how to write environment-related properties to a XML node.Understands utility methods related to GUI tests.Obtains the name of the local host.Understands how to decode base64 characters into an image.Understands how to encode a given image using the base64 algorithm.Understands base64 encoding and decoding of an image.Aggregates all <junit> XML formatter test suite data under a specific directory and transforms the results via XSLT.Transforms a JUnit XML report.Understands a JUnit XML report formatter that takes a screenshot when a GUI test fails.Understands taking a screenshot of the desktop and, encoding and writing the resulting image into a XML element.Understands how to filter a stack trace (by removing all
junit.runner.BaseTestRunner
.)Understands utility methods related to
s.OutputStream
Understands how to write information about a test suite to a XML node.Understands a collection of executed tests in a suite.Understands utility methods related to JUnit tests.Understands how to write information about a test to a XML node.Understands formatting a date using ISO8601-like pattern: yyyy-MM-ddTHH:mm:ss.Understands a copy of the originalXMLJUnitResultFormatter
, with flexibility for extension.Understands writing the contents of an XML document to an
.OutputStream