官网:https://testng.org/doc/index.html
Summary:
1.why testNg
2.Basic knowledge of testNG
3.testng basic element
4.Reference
If you looking for testNG apply to IPOS2.5 Project, click this link below:
fine tune script for iPOS 2.5 (introduce of testng framework)
1.why testNg
JUnit缺点:
-最初的设计,使用于单元测试,现在只用于各种测试。
-不能依赖测试
-配置控制欠佳(安装/拆卸)
-侵入性(强制扩展类,并以某种方式命名方法)
-静态编程模型(不必要的重新编译)
-不适合管理复杂项目应用,JUnit复杂项目中测试非常棘手。
-代码量大
TestNG(Next Generation)
开源自动化测试框
注解
java的面向对象功能
-支持综合类测试
参数化测试(使用testng.xml, 数据提供者)
-单独执行failed 的 case
produce HTML Reports of execution
-Annotations made testers life easy
2.Basic knowledge of testNG
What is TestNG in Selenium?
-TestNG in Selenium is a Java testing framework, inspired by JUnit and NUnit.
What is TestNG for?
-TestNG is an open-source test automation framework for Java.
What is TestNG method?
-TestNG Annotation are used to control the next method to be executed in the test script.
-TestNG annotations are defined before every method in the test code.
What is different between Selenium and TestNG?
-Selenium is a testing framework to test specifically the UI of the application how it behaves on browser.
-TestNG is a testing framework to test the unit, functional, E2E, integration testing of the application.
Does selenium need TestNG?
-This is not possible without using TestNG.
-The TestNG in Selenium provides an option, i.e., testng-failed.xml file in test-output folder.
-If you want to run only failed test cases means you run this XML file
What are the Benefits of TestNG?
-It gives the ability to produce HTML Reports of execution.
-Annotations made testers life easy.
-Test cases can be Grouped & Prioritized more easily.
-Parallel testing is possible.
-Generates Logs.
-Data Parameterization is possible.
What are the features of TestNG?
-TestNG uses more Java and OO features.
-Supporting testing integrated classes
-Separates compile-time test code from run-time configuration/data info.
-Flexible runtime configuration.
3.testng basic element
Summary of TestNG Annotations
AI写代码
1
@BeforeSuite: The annotated method will be run before all tests in this suite have run.
@AfterSuite: The annotated method will be run after all tests in this suite have run.
@BeforeTest: The annotated method will be run before any test method belonging to the classes inside the tag is run.
@AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the tag have run.
@BeforeGroups: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.
@AfterGroups: The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.
@BeforeClass: The annotated method will be run before the first test method in the current class is invoked.
@AfterClass: The annotated method will be run after all the test methods in the current class have been run.
@BeforeMethod: The annotated method will be run before each test method.
@AfterMethod: The annotated method will be run after each test method.
@Test: The annotated method is a part of a test case, has another parameter called “always run” which can only be set to either “true” or “false”.
4.Reference
Unfortunately, sometimes there is no general way to guess a correct solution or to learn a new things or both.
Guess the correct solution take experience and, occasionally, creativity.
However ,to make your life easier, here is some tips from my pass experience, Even though sometime things turn out to be quite the opposites, we still trying to make things more clear.
First things first, to learn a new framework, in this case , I use media resource to help me to get the environment installed.
Here is some links below that I found most helpful(request posted by Kevin~).
Literal:
https://cn.bing.com/search?q=introduce+of+testng+framework&qs=n&form=QBRE&sp=-1&pq=introduce+of+testng+framework&sc=0-29&sk=&cvid=12E0AB4ECC984BE985E1C49A10891843
TestNG基础教程 - 基于IntelliJ IDEA 创建TestNG test:
https://www.cnblogs.com/54tester/p/11516004.html
https://www.softwaretestinghelp.com/testng-tutorial/
https://cn.bing.com/search?q=introduce+of+testng+framework&qs=n&form=QBRE&sp=-1&pq=introduce+of+testng+framework&sc=0-29&sk=&cvid=12E0AB4ECC984BE985E1C49A10891843
http://blog.sina.com.cn/s/blog_bd6a57440102v4i4.html
https://cn.bing.com/search?q=testng+Dataprovider&PC=U316&FORM=CHROMN
IDEA+maven+java+TestNG环境搭建和验证:
https://blog.csdn.net/weixin_39430584/article/details/81939853?ops_request_misc=&request_id=&biz_id=102&utm_term=maven%20testng%20intellij&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-0-81939853.nonecase&spm=1018.2226.3001.4187
Video:5-1 TestNG的基本介绍和如何在maven中引用
https://www.bilibili.com/video/BV1ph411k7q4?p=6&spm_id_from=pageDriver
https://v.youku.com/v_show/id_XMzczNDA2NjQ2NA==
Video:【Selenium】Web自动化测试 Selenium基础到企业应用
https://www.bilibili.com/video/BV1wp4y1q75d?p=2&spm_id_from=pageDriver
-TestNG part:
https://www.bilibili.com/video/BV1wp4y1q75d?p=64
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。