ImageVerifierCode 换一换
格式:DOCX , 页数:51 ,大小:310.96KB ,
资源ID:6301717      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-6301717.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(TestNG使用说明Word格式文档下载.docx)为本站会员(b****4)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

TestNG使用说明Word格式文档下载.docx

1、离线安装首先下载testng离线包:1. 将解压后的文件.eclipse-testng离线包featuresorg.testng.eclipse_6.9.9.201510270734文件夹放到eclipse-features目录下2. 将解压后的文件.eclipse-testng离线包pluginsorg.testng.eclipse_6.9.8.201510130443文件夹放到 eclipse-plugins目录下3. 重启eclipse4. 验证是否安装成功,file-new-other-TestNgJar包下载地址下载地址:TestNG的官方文档原文请见http:/testng.org

2、/doc/documentation-main.htmlAnnotation注释BeforeSuiteAfterSuiteBeforeTestAfterTestBeforeGroupsAfterGroupsBeforeClassAfterClassBeforeMethodAfterMethodConfiguration information for a TestNG class:BeforeSuite:被注释的方法将在所有测试运行前运行AfterSuite:被注释的方法将在所有测试运行后运行BeforeTest:被注释的方法将在测试运行前运行,此方法在标记将要运行前。AfterTest: 被

3、注释的方法将在测试运行后运行BeforeGroups: 被配置的方法将在列表中的gourp前运行。这个方法保证在第一个属于这些组的测试方法调用前立即执行。AfterGroups: 被配置的方法将在列表中的gourp后运行。这个方法保证在最后一个属于这些组的测试方法调用后立即执行。BeforeClass: 被注释的方法将在当前类的第一个测试方法调用前运行。AfterClass:被注释的方法将在当前类的所有测试方法调用后运行。BeforeMethod: 被注释的方法将在每一个测试方法调用前运行。AfterMethod: 被注释的方法将在每一个测试方法调用后运行。alwaysRun对于每个bufor

4、e方法(beforeSuite, beforeTest, beforeTestClass 和 beforeTestMethod, 但是不包括 beforeGroups): 如果设置为true,被配置的方法将总是运行而不管它属于哪个组。对于after方法(afterSuite, afterClass, .): 如果设置为true,被配置的方法甚至在一个或多个先调用的方法失败或被忽略时也将运行。dependsOnGroups这个方法依赖的组列表dependsOnMethods这个方法依赖的方法列表enabled这个类的方法是否激活groups这个类或方法所属的分组列表inheritGroups如果

5、设置为true,这个方法被属于在类级别被Test annotation指定的组DataProvider标记一个方法用于为测试方法提供数据。被注释的方法必须返回Object, 其中每个Object可以指派为这个测试方法的参数列表。从这个DataProvider接收数据Test方法需要使用一个和当前注释相同名称的dataProvider名称name 这个DataProvider的名称name这个DataProvider的名称。如果未定义,dataprovider将自动命名为方法名。parallel如果设置为true,测试中的data provider会同时运行。默认值为false。Factory标

6、记方法作为一个返回对象的工厂,这些对象将被TestNG用于作为测试类。这个方法必须返回Object。Listeners在一个测试类中定义监听器。value一串数组类扩展org.testng.ITestNGListener.Parameters描述如何传递参数给Test方法。用于填充这个方法的参数的变量列表Test标记一个类或方法作为测试的一部分如果设置为true,这个测试方法将总是运行,甚至当它依赖的方法失败时。dataProvider这个测试方法的data provider的名称dataProviderClass用于查找data provider的类。如果不指定,将在当前测试方法所在的类或者

7、它的基类上查找data provider。如果这个属性被指定, 则data provider方法需要是指定类的static方法。当前方法依赖的组列表当前方法依赖的方法列表description当前方法的描述当前类的方法/方法是否被激活expectedExceptions测试方法期望抛出的异常列表。如果没有异常或者抛出的不是列表中的任何一个,当前方法都将标记为失败.当前类/方法所属的组列表invocationCount当前方法被调用的次数invocationTimeOut该测试所被调用次数的最大耗时,单位毫秒。如果调用次数未定义忽略本属性。priority测试方法优先级,低优先级的优先预订。su

8、ccessPercentage当前方法期望的成功率。singleThreaded如果设置为true,即使测试集现在运行方法设置为parallel=methods,测试类中的所有方法运行在同一个线程中。本属性只可以在类一级使用,忽略在方法一级的使用。注:依次调用本属性(已过时)timeOut当前方法容许花费的最大时间,单位毫秒。threadPoolSize当前方法的线程池大小。方法将被多线程调用,次数由invocationCount参数指定注意:如果invocationCount没有指定则这个属性将被忽略上面是TestNG中用到的annotation列表,从中我们可以看到TestNG提供的一些特

9、性1. before方法和after方法,带来了足够丰富的测试生命周期控制2. dependsOnGroups/dependsOnMethods 提供了依赖检查机制,并可以严格控制执行顺序3. DataProvider 使得对同一个方法的测试覆盖变的非常轻松,非常适合进行边界测试,只要给出多种测试数据就可以针对一个测试方法进行覆盖4. expectedExceptions 使得异常测试变的非常轻松5. invocationCount/threadPoolSize 终于可以简单的直接进行多线程测试了,这个绝对是junit的超级弱项,回想junit中那个万恶的System.exist(0).6.

10、timeOut 终于不用死等然后手工强行关闭测试,TestNG想的太周到了testng.xml调用TestNG由几种不同方法: * 使用testng.xml文件 * 从命令行这节描述testng.xml的格式。当前testng.xml的DTD文件可以从官方找到:http:/testng.org/testng-1.0.dtd.php。下面是testng.xml文件的一个例子:suite name=Suite1 verbose=1test name=Nopackageclassesclass name=NoPackageTest /classes/testRegression1test.sampl

11、e.ParameterSampletest.sample.ParameterTest/suite你可以指定包名替代类名:packagespackage name=test.sample/packages在这个例子中,TestNG将在包test.sample中查找所有的类,并只保留带有TestNG annotation的类。你同样可以指定包含或不包含的组和方法:groupsrunexclude name=brokenTestsinclude name=checkinTests/run/groupstest.IndividualMethodsTestmethodstestMethod/method

12、s/class你同样可以在testng.xml中定义新的组,指定属性的额外详细情况,比如是否并行运行测试,使用多少线程,是否运行junit测试,等等.请查看DTD文件了解完整的特性列表。运行TestNGTestNG可以以不同的方式调用: * Command line * Eclipse * IntelliJs IDEA1) 命令行假设你已经将TestNG加入到class path,调用TestNG最简单的方法事下面的:java org.testng.TestNG testng1.xml testng2.xml testng3.xml .必须指定最少一个描述你试图测试的TestNG suite的

13、xml文件。另外,下面的命令行参数可以使用:命令行参数列表操作参数说明-configfailurepolicyskip|continueTestNG是否继续执行suite中剩下的测试集,或者跳过Before*失败方法。模式习惯跳过。-dA directoryThe directory where the reports will be generated (defaults totest-output).-dataproviderthreadcountThe default number of threads to use for data providers when running tes

14、ts in parallel.This sets the default maximum number of threads to use for data providers when running tests in parallel. It will only take effect if the parallel mode has been selected (for example, with the -parallel option). This can be overridden in the suite definition.-excludegroupsA comma-sepa

15、rated list of groups.The list of groups you want to be excluded from this run.-groupsThe list of groups you want to run (e.g.windows,linux,regression).-listenerA comma-separated list of Java classes that can be found on your classpath.Lets you specify your own test listeners. The classes need to imp

16、lementorg.testng.ITestListener-methodsA comma separated list of fully qualified class name and method. For examplecom.example.Foo.f1,com.example.Bar.f2.Lets you specify individual methods to run.-methodselectorsA comma-separated list of Java classes and method priorities that define method selectors

17、.Lets you specify method selectors on the command line. For example:com.example.Selector1:3,com.example.Selector2:2-parallelmethods|tests|classesIf specified, sets the default mechanism used to determine how to use parallel threads when running tests. If not set, default mechanism is not to use para

18、llel threads at all. This can be overridden in the suite definition.-reporterThe extended configuration for a custom report listener.Similar to the-listeneroption, except that it allows the configuration of JavaBeans-style properties on the reporter instance.Example:-reporter com.test.MyReporter:met

19、hodFilter=*insert*,enableFiltering=trueYou can have as many occurences of this option, one for each reporter that needs to be added.-sourcedirA semi-colon separated list of directories.The directories where your javadoc annotated test sources are. This option is only necessary if you are using javad

20、oc type annotations. (e.g.src/testorsrc/test/org/testng/eclipse-plugin;src/test/org/testng/testng-suitenameThe default name to use for a test suite.This specifies the suite name for a test suite defined on the command line. This option is ignored if the suite.xml file or the source code specifies a

21、different suite name. It is possible to create a suite name with spaces in it if you surround it with double-quotes like this.-testclassA comma-separated list of classes that can be found in your classpath.A list of class files separated by commas (e.g.org.foo.Test1,org.foo.test2-testjarA jar file.S

22、pecifies a jar file that contains test classes. If atestng.xmlfile is found at the root of that jar file, it will be used, otherwise, all the test classes found in this jar file will be considered test classes.-testnameThe default name to use for a test.This specifies the name for a test defined on

23、the command line. This option is ignored if the suite.xml file or the source code specifies a different test name. It is possible to create a test name with spaces in it if you surround it with double-quotes -testnamesA comma separated list of test names.Only tests defined in a tag matching one of t

24、hese names will be run.-testrunfactoryA Java classes that can be found on your classpath.Lets you specify your own test runners. The class needs to implementorg.testng.ITestRunnerFactory.-threadcountThe default number of threads to use when running tests in parallel.This sets the default maximum num

25、ber of threads to use for running tests in parallel. It will only take effect if the parallel mode has been selected (for example, with the -parallel option). This can be overridden in the suite definition.-xmlpathinjarThe path of the XML file inside the jar file.This attribute should contain the path to a valid XML file inside the test jar (e.g.resources/testng.xml). The default istestng.xml, which means a file called at the root of the jar file. This option will be ignored unless-testjaris specif

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2