配置型的依赖测试,让依赖测试不局限于测试代码中,在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. 【jquery】字符ascii码转换函数

    js 字符ascii码转换函数 字符转ascii码:用charCodeAt();ascii码砖字符:用fromCharCode(); 看一个小例子 <script> str="A ...

  2. linker command failed with exit code 1 (use -v to see invocation)

    library not found for -|AFNetworking 错误内容如图所示: 解决方法:1. 如果没有安装pod,则安装pod,并导入项目AFNetworking参考:http://w ...

  3. [Android Pro] Service (startservice , bindservice , unbindservice, stopService)

    1: startService -------stopService (this will call onDestroy) 2: bindService -------unbindService    ...

  4. c++中有些重载运算符为什么要返回引用

    事实上,我们的重载运算符返回void.返回对象本身.返回对象引用都是可以的,并不是说一定要返回一个引用,只不过在不同的情况下需要不同的返回值. 那么什么情况下要返回对象的引用呢? 原因有两个: 允许进 ...

  5. NYOJ题目64鸡兔同笼

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsAAAAIZCAIAAAAnfB5fAAAgAElEQVR4nO3dO1LjygIG4LsJchZC7I ...

  6. ASP.NET MVC 使用带有短横线的html Attributes(转载)

    转载地址:http://www.nmtree.net/2013/10/25/asp-net-mvc-use-dash-in-html-attributes.html 情景再现 我们常常需要一个文本框来 ...

  7. .net学习之进程外Session的配置

    转载地址:http://www.cnblogs.com/rohelm/archive/2012/05/13/2498465.html 人人都知道怎么去使用session,但是初学者,尤其是自学的学生可 ...

  8. PostgreSQL的时间/日期函数使用

    PostgreSQL的常用时间函数使用整理如下: 一.获取系统时间函数 1.1 获取当前完整时间 select now(); david=# select now(); now ----------- ...

  9. Oracle【IT实验室】数据库备份与恢复之二:SQL*Loader

    2.1 基本知识 Oracle 的  SQL* LOADER  可以将外部格式化的文本数据加载到数据库表中.通常 与 SPOOL导出文本数据方法配合使用.     1.命令格式 SQLLDR keyw ...

  10. URAL 1966 Cycling Roads 点在线段上、线段是否相交、并查集

    F - Cycling Roads     Description When Vova was in Shenzhen, he rented a bike and spent most of the ...