TestWatcher和TestNG [英] TestWatcher and TestNG

查看:177
本文介绍了TestWatcher和TestNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,

我使用JUnit和TestWatcher硒(爪哇)一起。使用TestWatcher在成功与失败,我打电话给一个缺陷跟踪工具API锁定测试用例和缺陷。

I use JUnit and TestWatcher along with Selenium (Java). Using TestWatcher upon failure and success, I place calls to a bug tracking tool API to lock test cases and defects.

我现在想生成我Selenium测试运行的报告,并锁定测试用例和缺陷。我想使用TestNG来生成报告,但我TestWatcher不会与TestNG的工作。

I now want to generate a report of my Selenium test runs and lock the test cases and defects. I was thinking of using TestNG to generate reports but my TestWatcher won't work with TestNG.

我需要更换TestWatcher,因为我想现在使用TestNG替代JUnit的。

I need some replacement of TestWatcher as i want to now replace junit with TestNG.

任何人都知道什么样TestWatcher与TestNG的使用?

Anyone know anything like TestWatcher to use with TestNG?

感谢。

推荐答案

您想使用ITestListener(或更实际的,一个TestListener)。

You want to use an ITestListener (or more practically, a TestListener).

官方的概述是: http://testng.org/doc/documentation -main.html#TestNG的,听众和的Javadoc是的http:// TestNG的.ORG /的javadoc /组织/ TestNG的/ ITestListener.html

The official overview is: http://testng.org/doc/documentation-main.html#testng-listeners and the Javadoc is http://testng.org/javadocs/org/testng/ITestListener.html

为了节省您的时间,你可以扩展TestListenerAdapter,这将@Override所有为你的方法(所以你只需要使用您需要的@Overrides)。

To save you some time, you can extend a TestListenerAdapter, which will @Override all of the methods for you (so you only have to use the @Overrides you need).

与JUnit,TestNG的测试监听器将你的@Test方法之后执行的,和你之前@AfterMethod。也不像JUnit中,测试监听器将传递作为参数的ITestResult对象,让您通过Java反射访问所有的领域,你的测试类的方法。

Unlike JUnit, TestNG test listeners will be executed after your @Test method, and before your @AfterMethod. Also unlike JUnit, the Test Listener will have an ITestResult object passed in as a parameter, allowing you to access all of the fields and methods of your test class via Java reflection.

这篇关于TestWatcher和TestNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆