12
返回列表 发新帖
楼主: AlexQin

Tutorial #12 – Introduction to TestNG

[复制链接]
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
11#
 楼主| 发表于 2017-6-13 09:16 | 只看该作者
Conclusion
Through this tutorial, we tried to make you acquainted with a java based testing framework named as TestNG. We started off the session with the installation of the framework and moved with the script creation and advance topics. We discussed all the annotations provided by TestNG. We implemented and executed our first TestNG test script using annotations and assert statements.
Article summary:
  • TestNG is an advance framework designed in a way to leverage the benefits by both the developers and testers.
  • TestNG is an open source framework which is distributed under the Apache software License and is readily available for download.
  • TestNG is considered to be superior to JUnit because of its advance features.
  • Features of TestNG
    • Support for Annotations
    • Advance execution methodology that do not require test suites to be created
    • Support for parameterization
    • Support for Data Driven Testing using Dataproviders
    • Setting execution priorities for the test methods
    • Supports threat safe environment when executing multiple threads
    • Readily supports integration with various tools and plug-ins like build tools (Ant, Maven etc.), Integrated Development Environment (Eclipse).
    • Facilitates user with effective means of Report Generation using ReportNG

  • Advantages of TestNG over JUnit
    • Added advance and easy annotations
    • Execution patterns can be set
    • Concurrent execution of test scripts
    • Test case dependencies can be set

  • TestNG is freely available and can be easily installed in the Eclipse IDE using Eclipse Market.
  • Upon installation, TestNG would be available as a library within the Eclipse environment.
  • Create a new Java Project and configure the build path using TestNG library.
  • Create a new TestNG class by expanding the created TestNG project and traverse to its “src” folder. Right click on the “src” package and navigate to New -> Other. Select TestNG class option.
  • @Test is one of the annotations provided by TestNG. This annotation lets the program execution to know that method annotated as @Test is a test method. To be able to use different TestNG annotations, we need to import the package “import org.testng.annotations.*”.
  • There is no need of main() method while creating test scripts using TestNG.
  • We use Assert class while comparing expected and the actual value. Assert class is used to perform various verifications. To be able to use different assertions, we are required to import “import org.testng.Assert”.
  • If a test script is composed of more than one test methods, the execution priority and sequence can be set using TestNG annotation “@Test” and by setting a value for the “priority” parameter.
  • TestNG has a capability of generating human readable test execution reports automatically. These reports can be viewed in any of the browser and it can also be viewed using Eclipse’s built – in browser support.

Next Tutorial #13: Moving ahead with the upcoming tutorials in the Selenium series, we would concentrate on handling the various types of web elements available on the web pages. Therefore, in the next tutorial, we would concentrate our focus on “dropdowns” and will exercise their handling strategies. We would also discuss about WebDriver’s Select class and its methods to select values in the dropdowns.
A remark for the readers: While our next tutorial of the Selenium series is in the processing mode, readers can start creating their own basic WebDriver scripts using TestNG framework.
For more advance scripts and concepts, include as many annotations and assertions in your TestNG classes and execute them using TestNG environment. Also analyze the HTML reports generated by TestNG.

使用道具 举报

回复
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
12#
 楼主| 发表于 2017-6-13 09:16 | 只看该作者

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表