[英]Taking Screenshot of failed Fest JUnit test
I am currently writing Fest Junit test cases that will be later ran on a Hudson test server. 我目前正在编写Fest Junit测试用例,这些用例随后将在Hudson测试服务器上运行。 I would like to have them take desktop screen shots if any test case fails. 如果有任何测试用例失败,我希望他们进行桌面截屏。 I found this url that has a tutorial on how to set this up: http://fest.codehaus.org/Taking+Screenshots+of+JUnit+Test+Failures but the tests don't even run locally. 我发现此URL包含有关如何进行设置的教程: http : //fest.codehaus.org/Taking+Screenshots+of+JUnit+Test+Failures,但是测试甚至不在本地运行。
Here is a skimmed down copy of the java code that I am attempting to run: 这是我尝试运行的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
}
And my JUnit Ant task that I am attempting to run: 以及我尝试运行的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>
Any help would be great. 任何帮助都会很棒。
A screen shot of the error thrown by Junit in the report Junit在报告中引发的错误的屏幕截图
Here is a quick solution that I found after stumbling upon some source code on the internet (if anyone stumbles upon this thread): the java code: 这是在绊倒互联网上的某些源代码(如果有人偶然发现此线程)后发现的一种快速解决方案:Java代码:
@GUITest
public void testAddingNewUser() throws InterruptedException{
//java code
needed to be 需要成为
@Test
@GUITest
public void testAddingNewUser() throws InterruptedException{
//java code
Everything else seemed to be correct 其他一切似乎都是正确的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.