mac eclipse testngg.装好了但是用不了,有哪位大神可以帮帮我。很急

16036人阅读
软件测试-测试框架之TestNg(13)
教你解决为什么TestNG中方法加了@Test注解,也在配置文件中配置了,但是方法就是不执行!
在使用TestNG进行测试时,使用配置文件的方式更容易于维护,但是经常遇到明明方法写了也配置执行了,但是run的时候代码就没有执行
看代码:(仔细看注释!)
* Title: TestngMethods
* 对应配置文件testng-methods.xml
* Description: Testng的methods测试及配置,参考testng-methods.xml,如果不设置
* exclude和include,默认执行当前测试类时,带有返回值的方法不会被执行
* 如果想执行多个同类型或者命名方式类似的多个方法时,可以使用方法组测试,
* '.*'表示一个或多个字符,如果方法命名方式不同,那么可以采用组测试方法进行测试,参考TestGroups
* 注:文档错误!
* 5.1 - Test methods Test methods are annotated with @Test. Methods annotated
* with @Test that happen to return a value will be ignored, unless you set
* allow-return-values to true in your testng.xml:
* &suite allow-return-values=&true&&
* &test allow-return-values=&true&&
* 此处在&test &中配置allow-return-values属性无效,测试依旧不会被执行
* Company:
* @author : Dragon
* @date : 日
public class TestngMethods {
 * 默认情况下这个方法将被忽略,如果需要执行,需要在xml中配置allow-return-values=&true&
 * 
 * @return
public String getName() {
System.err.println(&return name.... getName()&);
return &name&;
public void funtest() {
System.err.println(&this is funtest......&);
public void saveMethod1() {
System.err.println(&this is saveMethod1......&);
public void saveMethod2() {
System.err.println(&this is saveMethod2......&);
public void saveMethod3() {
System.err.println(&this is saveMethod3......&);
配置文件:testng-methods.xml
&?xml version=&1.0& encoding=&UTF-8&?&
&!DOCTYPE suite SYSTEM &http://testng.org/testng-1.0.dtd&&
&!-- allow-return-values 默认值为FALSE,表示返回值将被忽略 --&
&suite name=&framework_testng& allow-return-values=&true&&
&test verbose=&2& name=&TestMethods&&
&class name=&com.dragon.testng.annotation.TestngMethods&&
&exclude name=&funtest&&&/exclude&
&include name=&getName&&&/include&
&include name=&save.*&&&/include&
&/methods&
&/classes&
运行结果:
return name.... getName()
this is saveMethod1......
this is saveMethod2......
this is saveMethod3......
PASSED: getName
PASSED: saveMethod1
PASSED: saveMethod2
PASSED: saveMethod3
===============================================
TestMethods
Tests run: 4, Failures: 0, Skips: 0
===============================================
如果我忍让,
别认为我退缩。因为我明白,忍一忍风平浪静,让一让天高海阔。
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:692532次
积分:4775
积分:4775
排名:第5402名
原创:78篇
评论:114条
文章:14篇
阅读:419271
阅读:60397
文章:12篇
阅读:84716
(1)(1)(1)(6)(1)(2)(1)(6)(14)(3)(6)(5)(5)(2)(3)(1)(1)(2)(1)(1)(2)(1)(2)(3)(7)(4)(1)Eclipse安装TestNG插件 - xusweeter - 博客园
TestNG是什么?
TestNG按照其文档的定义是: TestNG是一个测试框架,其灵感来自JUnit和NUnit的,但引入了一些新的功能,使其功能更强大,使用更方便。 TestNG是一个开源自动化测试框架;TestNG表示下一代。 TestNG是类似于JUnit(特别是JUnit 4),但它不是一个JUnit扩展。它的灵感来源于JUnit。它的目的是优于JUnit的,尤其是当测试集成的类。 TestNG的创造者是Cedric Beust(塞德里克·博伊斯特)。TestNG消除了大部分的旧框架的限制,使开发人员能够编写更加灵活和强大的测试。 因为它在很大程度上借鉴了Java注解(JDK5.0引入的)来定义的测试,它也可以告诉你如何使用这个新功能在真实的Java语言生产环境中。 TestNG的特点
注解 TestNG使用Java和面向对象的功能 支持综合类测试(例如,默认情况下,没有必要创建一个新的测试每个测试方法的类的实例) 独立的编译时间测试代码运行时配置/数据信息 灵活的运行时配置 主要介绍“测试组”。当编译测试,只要问TestNG运行所有的“前端”的测试,或“快”,“慢”,“数据库”等 支持依赖测试方法,并行测试,负载测试,局部故障 灵活的插件API 支持多线程测试 Eclipse安装TestNG TestNG官网地址: 在官网上部导航区域点击“Download”链接,该页面介绍了集成TestNG的不同方式。 在“Eclipse plug-in”区域介绍了两种Eclipse安装插件的方式。 硬性要求:JDK1.7以上版本、Eclipse4.2以上版本。 Java 1.7+ is required for running the TestNG for Eclipse plugin. Eclipse 4.2 and above is required. Eclipse 3.x is NOT supported any more, please update your Eclipse to 4.2 or above. 两种在线安装方式: 1、通过Eclipse Marketplace安装; &&&& 在浏览器中拖拽“Drag to your running Eclipse workspace to install TestNG for Eclipse”链接至Eclipse的工作空间,即可启动Eclipse Marketplace进行安装TestNG。
2、通过Update Site安装; &&&& 通过update site也可以进行插件的安装,方法是:在Eclipse中点击Help菜单,选择Install New Software选项,在弹出页面中输入安装地址即可安装。 &&&&
& 离线安装TestNG插件: 受网络等因素影响,在线安装方式速度比较慢,可以通过如下方式离线安装TestNG插件。 通过浏览器直接访问网址,
选择最下部的zipped文件夹链接;
选择版本,如:“6.10.0./”
点击超链接,即可下载离线安装文件。 将安装文件解压至eclipse的dropin目录后重启Eclipse完成插件安装。
验证插件安装是否成功 打开Eclipse,新建-other,选择“TestNG——&TestNG Class”。
出现这个说明插件安装成功。

我要回帖

更多关于 eclipse testng 的文章

 

随机推荐