配置型的依赖测试,让依赖测试不局限于测试代码中,在XML文件中进行灵活的依赖配置

原创文章,版权所有,允许转载,标明出处:http://blog.csdn.net/wanghantong

Javacode:

  1. /**
  2. *
  3. * <p>
  4. * Title: TestngDependencyOnXML
  5. * </p>
  6. *
  7. * <p>
  8. * Description: 不使用注解的情况下,通过对testng-xml来进行依赖配置
  9. *
  10. * 执行原则:
  11. * 被依赖的group最先执行,如果某个group没有被配置成被依赖,那么它将在被依赖的group之后执行,最后执行的是需要依赖其它group的方法
  12. * ,如果都没有配置依赖,则按顺序执行.一个方法有多个依赖时用空格隔开
  13. * </p>
  14. *
  15. * <p>
  16. * Company:
  17. * </p>
  18. *
  19. * @author : Dragon
  20. *
  21. * @date : 2014年10月21日
  22. */
  23. public class TestngDependencyOnXML {
  24. @Test(groups = { "ss" })
  25. public void a() {
  26. System.out.println("this is method a, Groups ss");
  27. }
  28. @Test(groups = { "ss" })
  29. public void b() {
  30. System.out.println("this is method b,     Groups ss");
  31. }
  32. @Test(groups = { "xx" })
  33. public void c() {
  34. System.out.println("this is method c ,Groups xx");
  35. }
  36. @Test(groups = { "xx" })
  37. public void d() {
  38. System.out.println("this is method d, Groups xx");
  39. }
  40. @Test(groups = { "yy" })
  41. public void e() {
  42. System.out.println("this is method e , Groups yy");
  43. }
  44. }

配置文件:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
  3. <suite name="framework_testng">
  4. <test name="testng-dependOnXML" >
  5. <groups >
  6. <dependencies >
  7. <group name="ss" depends-on="xx yy" />
  8. </dependencies>
  9. </groups>
  10. <classes>
  11. <class name="com.dragon.testng.annotation.TestngDependencyOnXML" />
  12. </classes>
  13. </test>
  14. </suite>

运行结果:

  1. this is method c ,Groups xx
  2. this is method d, Groups xx
  3. this is method e , Groups yy
  4. this is method a, Groups ss
  5. this is method b,     Groups ss
  6. ===============================================
  7. framework_testng
  8. Total tests run: 5, Failures: 0, Skips: 0
  9. ===============================================

总结: 被依赖的group最先执行,如果某个group没有被配置成被依赖,那么它将在被依赖的group之后执行,最后执行的是需要依赖其它group的方法,如果都没有配置依赖,则按顺序执行.一个方法有多个依赖时用空格隔开

TestNg依赖详解(三)------灵活的文件配置依赖的更多相关文章

  1. java分享第十四天(TestNG Assert详解)

     TestNG Assert 详解org.testng.Assert 用来校验接口测试的结果,那么它提供哪些方法呢? 中心为Assert测试类,一级节点为方法例如assertEquals,二级结点为参 ...

  2. Android 之窗口小部件详解(三)  部分转载

    原文地址:http://blog.csdn.net/iefreer/article/details/4626274. (一) 应用程序窗口小部件App Widgets 应用程序窗口小部件(Widget ...

  3. JAVA TestNG单元测试详解

    TestNG单元测试详解   by:授客 QQ:1033553122 1. 测试环境 2 2. 介绍 2 3. Annotation 2 4. testng.xml 3 4.1. 例1 3 4.2. ...

  4. pscp使用详解 Windows与Linux文件互传工具

    pscp使用详解 Windows与Linux文件互传工具 pscp使用方法详解:pscp是putty安装包所带的远程文件传输工具,是一款十分常见windows与linux系统之间文件互传的工具,使用方 ...

  5. .NET DLL 保护措施详解(三)最终效果

    针对.NET DLL 保护措施详解所述思路完成最终的实现,以下为程序包下载地址 下载 注意: 运行环境为.net4.0,需要安装VS2015 C++可发行组件包vc_redist.x86.exe.然后 ...

  6. elasticSearch+spring 整合 maven依赖详解

    摘自:http://www.mayou18.com/detail/nTxPQSyu.html [Elasticsearch基础]elasticSearch+spring 整合 maven依赖详解 Ma ...

  7. WebSocket安卓客户端实现详解(三)–服务端主动通知

    WebSocket安卓客户端实现详解(三)–服务端主动通知 本篇依旧是接着上一篇继续扩展,还没看过之前博客的小伙伴,这里附上前几篇地址 WebSocket安卓客户端实现详解(一)–连接建立与重连 We ...

  8. logback -- 配置详解 -- 三 -- <encoder>

    附: logback.xml实例 logback -- 配置详解 -- 一 -- <configuration>及子节点 logback -- 配置详解 -- 二 -- <appen ...

  9. python设计模式之装饰器详解(三)

    python的装饰器使用是python语言一个非常重要的部分,装饰器是程序设计模式中装饰模式的具体化,python提供了特殊的语法糖可以非常方便的实现装饰模式. 系列文章 python设计模式之单例模 ...

随机推荐

  1. 【leetcode】Convert Sorted List to Binary Search Tree (middle)

    Given a singly linked list where elements are sorted in ascending order, convert it to a height bala ...

  2. iOS蓝牙4.0

    iOS的蓝牙用到了  CoreBluetooth 框架 首先导入框架 #import <CoreBluetooth/CoreBluetooth.h> 我们需要一个管理者来管理蓝牙设备,CB ...

  3. September 20th 2016 Week 39th Tuesday

    Failure is not fatal, but failure to change might be. 失败并不致命,但无法改变却可能是致命的. I need change, but it see ...

  4. sql 查询最近30分钟或者自定义时间数据

    ) FROM dual; 30分钟或者自定义

  5. Google 如何修复 TrustManager 实施方式不安全的应用

    引用谷歌市场的帮助说明:https://support.google.com/faqs/answer/6346016 本文面向的是发布的应用中 X509TrustManager 接口实施方式不安全的开 ...

  6. json_encode() 和 json_decode()

    php json_decode返回数据js的处理,json_decode后,返回到前台的数据如:encode_str => {"green":10,"size&qu ...

  7. vim 查找时忽略大小写

    :set ic 忽略大小写#ignorecase :set noic 不忽略大小写#noignorecase

  8. Ubuntu下安装Python3.4

    转自:http://blog.sina.com.cn/s/blog_7cdaf8b60102vf2b.html 1. 通过命令行安装Python3.4,执行命令:sudo apt-get instal ...

  9. Server.MapPath查询路径那几件事

    主要总结Server.MapPath 这个方法的使用以及使用的场景,不是什么时候都适合使用: 1.实现功能: Server.MapPath能够获取指定URL相对服务器的物理路径,在IIS服务端,能够根 ...

  10. SQL脚本书写的几点建议

    1.索引很关键,创建合理的索引,提升查询速度:            DBCC FREEPORCCACHE       DBCC DROPCLEANBUFFERS                    ...