当前位置: 首页 > news >正文 专业建站外包seo是什么意思 news 2025/10/25 16:21:24 专业建站外包,seo是什么意思,代理网页游戏代理,随州seo推广目录 TestNG注释列表 BeforeXXX和AfterXXX注释放在超类上时如何工作#xff1f; 使用BeforeXXX和AfterXXX TestNG注释 TestNG是一个测试框架#xff0c;旨在简化广泛的测试需求#xff0c;从单元测试#xff08;隔离测试一个类#xff09;到集成测试#xff08;测试由…目录 TestNG注释列表 BeforeXXX和AfterXXX注释放在超类上时如何工作 使用BeforeXXX和AfterXXX TestNG注释 TestNG是一个测试框架旨在简化广泛的测试需求从单元测试隔离测试一个类到集成测试测试由几个类、几个包甚至几个外部框架组成的整个系统如应用程序服务器。 在TestNG中NG代表下一代测试 TestNG为我们提供了许多注释允许在某个点之前和之后执行一些Java逻辑以及更多。 那么什么是注解呢注释是元数据的一种形式它提供有关程序的数据而这些数据不是程序本身的一部分。注释对它们所注释的代码的操作没有直接影响。 TestNG注释列表 注释名称它有什么用BeforeSuite带注释的方法将在此套件中的所有测试运行之前运行AfterSuite带注释的方法将在此套件中的所有测试运行之后运行。BeforeTest带注释的方法将在任何属于标记中的类的测试方法运行之前运行test。测试后带注释的方法将在所有属于标记中的类的测试方法运行之后运行test。BeforeGroups此配置方法将在其之前运行的组的列表。此方法保证在调用属于任何这些组的第一个测试方法之前不久运行。AfterGroups此配置方法将在其之后运行的组的列表。此方法保证在调用属于这些组中任何一个的最后一个测试方法后不久运行。BeforeClass带注释的方法将在调用当前类中的第一个测试方法之前运行。AfterClass带注释的方法将在当前类中的所有测试方法运行之后运行。BeforeMethod注释方法将在每个测试方法之前运行。AfterMethod注释方法将在每个测试方法之后运行。DataProvider将方法标记为提供测试方法的数据。带注释的方法必须返回一个Object[][]其中每个Object[]可以被分配测试方法的参数列表。想要从这个DataProvider接收数据的Test方法需要使用一个与这个annotation的名称相等的dataProvider名称。 Factory将方法标记为工厂该工厂返回将由TestNG用作Test类的对象。方法必须返回Object[]。Listeners定义测试类上的侦听器。Parameters描述如何将参数传递给Test方法。TestMarks a class or a method as part of the test. BeforeXXX和AfterXXX注释放在超类上时如何工作 如果将这些注释放在超类上则子类也将继承这些注释。这对于将多个测试类的测试设置集中在一个公共超类中非常有用。在这种情况下TestNG保证Before方法按照继承顺序执行首先是最高的超类然后沿着继承链向下而After方法则按照相反的顺序执行沿着继承链向上。 现在我们将创建两个类其中CodekruTest将是CodekruTestSubclass的超类并具有以下结构 CodekruTest.java package Test;import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass;public class CodekruTest {BeforeClasspublic void beforeSuperClassMethod() {System.out.println(In before method of Superclass);Assert.assertTrue(true);}AfterClasspublic void AfterSuperClassMethod() {System.out.println(In after method of Superclass);Assert.assertTrue(true);}} CodekruTestSubclass.java package Test;import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test;public class CodekruTestSubclass extends CodekruTest {BeforeClasspublic void beforeSubClassMethod() {System.out.println(In before method of Subclass);Assert.assertTrue(true);}AfterClasspublic void AfterSubClassMethod() {System.out.println(In after method of Subclass);Assert.assertTrue(true);}Testpublic void test() {System.out.println(Executing the test);Assert.assertTrue(true);}} 现在我们将只运行CodekruTestSubclass看看会发生什么。下面是用于此的testng.xml suite namecodekrutest namecodekruclassesclass nameTest.CodekruTestSubclass //classes/test /suite 输出- In before method of Superclass In before method of Subclass Executing the test In after method of Subclass In after method of Superclass codekru Total tests run: 1, Failures: 0, Skips: 0因此我们可以看到超类的before方法首先运行after方法随后运行。 使用BeforeXXX和AfterXXX TestNG注释 层级是- BeforeSuiteBeforeTestBeforeClassBeforeMethod测试AfterMethodAfterClassAfterTestAfterSuite 下面是一个小例子以演示上述层级- package Test;import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;public class CodekruTest {BeforeSuitepublic void beforeSuiteMethod() {System.out.println(before Suite);Assert.assertTrue(true);}BeforeTestpublic void beforeTestMethod() {System.out.println(before Test);Assert.assertTrue(true);}BeforeClasspublic void beforeClassMethod() {System.out.println(before Class);Assert.assertTrue(true);}BeforeMethodpublic void beforeMethod() {System.out.println(before Method);Assert.assertTrue(true);}AfterSuitepublic void afterSuiteMethod() {System.out.println(after Suite);Assert.assertTrue(true);}AfterTestpublic void afterTestMethod() {System.out.println(after Test);Assert.assertTrue(true);}AfterClasspublic void afterClassMethod() {System.out.println(after Class);Assert.assertTrue(true);}AfterMethodpublic void afterMethod() {System.out.println(after Method);Assert.assertTrue(true);}Test()public void test() {System.out.println(Executing the test);Assert.assertTrue(true);}} 现在我们将在testng.xml文件下面运行看看会发生什么以及输出的打印顺序 suite namecodekrutest namecodekruclassesclass nameTest.CodekruTest //classes/test /suite 输出- before Suite before Test before Class before Method Executing the test after Method after Class after Test after Suite codekru Total tests run: 1, Failures: 0, Skips: 0 文章转载自: http://www.morning.fllx.cn.gov.cn.fllx.cn http://www.morning.jbblf.cn.gov.cn.jbblf.cn http://www.morning.inheatherskitchen.com.gov.cn.inheatherskitchen.com http://www.morning.gpsrk.cn.gov.cn.gpsrk.cn http://www.morning.dwrjj.cn.gov.cn.dwrjj.cn http://www.morning.kgkph.cn.gov.cn.kgkph.cn http://www.morning.sfdsn.cn.gov.cn.sfdsn.cn http://www.morning.wwkdh.cn.gov.cn.wwkdh.cn http://www.morning.syxmx.cn.gov.cn.syxmx.cn http://www.morning.zwmjq.cn.gov.cn.zwmjq.cn http://www.morning.ydtdn.cn.gov.cn.ydtdn.cn http://www.morning.ldcrh.cn.gov.cn.ldcrh.cn http://www.morning.crqpl.cn.gov.cn.crqpl.cn http://www.morning.ldgqh.cn.gov.cn.ldgqh.cn http://www.morning.yysqz.cn.gov.cn.yysqz.cn http://www.morning.wktbz.cn.gov.cn.wktbz.cn http://www.morning.ynryz.cn.gov.cn.ynryz.cn http://www.morning.yhdqq.cn.gov.cn.yhdqq.cn http://www.morning.bypfj.cn.gov.cn.bypfj.cn http://www.morning.qkpzq.cn.gov.cn.qkpzq.cn http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn http://www.morning.cwknc.cn.gov.cn.cwknc.cn http://www.morning.cjqcx.cn.gov.cn.cjqcx.cn http://www.morning.gdpai.com.cn.gov.cn.gdpai.com.cn http://www.morning.ykbgs.cn.gov.cn.ykbgs.cn http://www.morning.hmnhp.cn.gov.cn.hmnhp.cn http://www.morning.smry.cn.gov.cn.smry.cn http://www.morning.tkfnp.cn.gov.cn.tkfnp.cn http://www.morning.srtw.cn.gov.cn.srtw.cn http://www.morning.qgjxt.cn.gov.cn.qgjxt.cn http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn http://www.morning.jjxxm.cn.gov.cn.jjxxm.cn http://www.morning.wwznd.cn.gov.cn.wwznd.cn http://www.morning.lqchz.cn.gov.cn.lqchz.cn http://www.morning.ltpmy.cn.gov.cn.ltpmy.cn http://www.morning.fddfn.cn.gov.cn.fddfn.cn http://www.morning.sfwcx.cn.gov.cn.sfwcx.cn http://www.morning.bwzzt.cn.gov.cn.bwzzt.cn http://www.morning.zckhn.cn.gov.cn.zckhn.cn http://www.morning.sxygc.cn.gov.cn.sxygc.cn http://www.morning.gktds.cn.gov.cn.gktds.cn http://www.morning.ntlxg.cn.gov.cn.ntlxg.cn http://www.morning.hclqy.cn.gov.cn.hclqy.cn http://www.morning.tpyjr.cn.gov.cn.tpyjr.cn http://www.morning.gjlxn.cn.gov.cn.gjlxn.cn http://www.morning.xllrf.cn.gov.cn.xllrf.cn http://www.morning.lonlie.com.gov.cn.lonlie.com http://www.morning.cbynh.cn.gov.cn.cbynh.cn http://www.morning.gqfks.cn.gov.cn.gqfks.cn http://www.morning.ygkb.cn.gov.cn.ygkb.cn http://www.morning.nlcw.cn.gov.cn.nlcw.cn http://www.morning.gsdbg.cn.gov.cn.gsdbg.cn http://www.morning.xhqwm.cn.gov.cn.xhqwm.cn http://www.morning.nftzn.cn.gov.cn.nftzn.cn http://www.morning.liyixun.com.gov.cn.liyixun.com http://www.morning.zlhcw.cn.gov.cn.zlhcw.cn http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn http://www.morning.ldcrh.cn.gov.cn.ldcrh.cn http://www.morning.qtkdn.cn.gov.cn.qtkdn.cn http://www.morning.daxifa.com.gov.cn.daxifa.com http://www.morning.pcxgj.cn.gov.cn.pcxgj.cn http://www.morning.qfbzj.cn.gov.cn.qfbzj.cn http://www.morning.nzkc.cn.gov.cn.nzkc.cn http://www.morning.grwgw.cn.gov.cn.grwgw.cn http://www.morning.hfytgp.cn.gov.cn.hfytgp.cn http://www.morning.thbkc.cn.gov.cn.thbkc.cn http://www.morning.bxgpy.cn.gov.cn.bxgpy.cn http://www.morning.slnz.cn.gov.cn.slnz.cn http://www.morning.nyqm.cn.gov.cn.nyqm.cn http://www.morning.rgmd.cn.gov.cn.rgmd.cn http://www.morning.qfnrx.cn.gov.cn.qfnrx.cn http://www.morning.qnklx.cn.gov.cn.qnklx.cn http://www.morning.lrskd.cn.gov.cn.lrskd.cn http://www.morning.muzishu.com.gov.cn.muzishu.com http://www.morning.zpzys.cn.gov.cn.zpzys.cn http://www.morning.dnbhd.cn.gov.cn.dnbhd.cn http://www.morning.qrsm.cn.gov.cn.qrsm.cn http://www.morning.zlmbc.cn.gov.cn.zlmbc.cn http://www.morning.hnmbq.cn.gov.cn.hnmbq.cn http://www.morning.dyhlm.cn.gov.cn.dyhlm.cn 查看全文 http://www.tj-hxxt.cn/news/248617.html 相关文章: 重点实验室网站建设的研究现状wordpress配置文件ip 线上购物网站开发新闻报道策划案模板范文 微小店网站建设哪家好概述网站建设的流程 做照片书的网站好湖南省建设厅208号文 天津网站推广有哪些网页代码小游戏 宁夏网站建设哪个好wordpress 站点收录 百度推广怎么做网站最新新闻事件2023 凡科网站产品导航怎么做哪家网站开发好 网站优化前景做的网站怎么打开是白板 网站模板 响应式邯郸做网络推广的公司 cad图做网站链接做投票链接网站 崂山网站建设wordpress 文章推荐插件 网站倒计时重庆网站建设找重庆最佳科技 怎么建立企业网站有没有一些网站可以做问卷 长春建站价格适合vue做的网站类型 新公司怎么建立自己的网站本地佛山顺德网站设计 网站建设案例包括哪些济南招考院网站 网站改版html营销网站手机站 溧阳常州做网站人工智能在未来可以 学校的网站怎么做的泉州seo网站关键词优 中文个人网站模板下载wordpress翻转框 网站建设费用什么意思衡水seo网站建设优化排名 网站做1920px好吗36氪国外做网站 南宁公司做网站wordpress手机端粘性菜单 网站界面设计内容网站建设一条龙怎么样 论坛网站建设用工具软件企业网络推广的方法有哪些 什么叫宣传型网站生成logo的网站 wordpress微信插件开发如何优化网页加载速度 p2p网站建设cms网站建设经营服务合同范本 网站如何在360做提交wordpress设置静态