TestNG简介
来源:互联网 发布:java怎么选择权限框架 编辑:程序博客网 时间:2024/06/05 03:41
前言
前几天在跑一个项目的时候发现它的测试框架是TestNG,以前没接触过,不过看起来跟JUnit差不多,后来通过查阅资料发现有个说法:开发人员用Junit写单元测试,测试人员用TestNG写自动化测试。由此可见TestNG比JUnit要更加强大,今天我们就看看测试人员使用的TestNG究竟是啥,比JUnit强在哪里。
正题
1.TestNG介绍
TestNG(Test Next Generation),是基于JUnit和NUnit并进行了改进的测试框架,它的功能很强大,而且简单易用。
下面是官网的解释:
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use, such as:
1)Annotations.
2)Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per
3)test class, etc...).
4)Test that your code is multithread safe.
5)Flexible test configuration.
6)Support for data-driven testing (with @DataProvider).
7)Support for parameters.
8)Powerful execution model (no more TestSuite).
9)Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
10)Embeds BeanShell for further flexibility.
11)Default JDK functions for runtime and logging (no dependencies).
12)Dependent methods for application server testing.
TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...
ps:详情可参考TestNG官网 http://testng.org/doc/index.html
2.特点
上面已经介绍了TestNG的特性,我们可以主要归为几个:
1)更丰富的annotation。
2)使用xml配置文件可以任意组合出需要的各种测试。
3)命令行参数让每一次测试更灵活。
3.Eclipse中安装TestNG
要想使用TestNG不仅需要相应的jar包还需要对应的插件,安装方式有很多种,对于第一次接触的东西我们可以直接通过Help->Eclipse Marketplace 然后输入tTestNG进行搜索即可。
安装成功后我们就可以看到了
4.简单示例
package com.dan.test;import org.junit.AfterClass;import org.junit.BeforeClass;import org.testng.annotations.Test;public class TestNG1 { @BeforeClass public void beforeClass() { System.out.println("this is before class"); } @Test public void TestNgExample() { System.out.println("this is TestNG test case"); } @AfterClass public void afterClass() { System.out.println("this is after class"); }}
1 0
- TestNG简介
- TestNG简介
- TestNG入门教程-1-TestNG简介
- Testng入门基本简介
- TestNG系列教程一:TestNG简介
- TestNG入门教程-4-Testng中注释简介
- TestNG 学习总结 - 简介(一)
- TestNG学习记录--------简介和安装
- TestNG
- testng
- testng
- TestNG
- TestNG
- TestNG
- TestNG
- testng
- TestNG
- testNG
- C++之struct构造函数
- linux命令英文缩写的含义(方便记忆)
- 学习vi和vim编辑器(17):vim的多窗口功能(2)
- hdoj 2095 find your present (2)
- 编程之美"求二进制中1的个数"
- TestNG简介
- fft
- android:模拟水波效果的自定义View
- redis查看连接数
- mybatis 对于tinyint 类型解析问题
- HTTP返回码中301与302的区别
- Android调用webservice接收json
- 在xcode6.1和ios10.10.1环境下实现app发布
- 手机号,邮箱,车牌号合法性验证(手机号如果要支持更多的运营商的号码,比如177,要改一下正则表达式)