https://www.cnblogs.com/baixiaozheng/p/4989856.html
1、可借助Eclipse的Marketplace来安装TestNG Eclipse插件
a、打开eclipse分别点击help-Eclipse Marketplace进入如下界面,在如下界面的Find后面输入testng然后点击GO按钮,最后点击Install
b、点击Install后进入以下界面,当下图中的进度条执行完毕后,选择以下选项并点击confirm按钮
以下两种方法可以安装TestNG Eclipse插件:
第一种,离线安装
发现很多同学和我一样无法在线安装testNg,现在分享一个离线安装的方法,及安装文件,希望能够帮到大家。
1.下载附件,并解压。(后面有),或者百度网盘http://pan.baidu.com/s/1i3y1QtR
2.将解压后的文件..\eclipse-testng离线包\features\目录下的文件夹org.testng.eclipse_6.8.6.20130607_0745放到eclipse--》features目录下
3.将解压后的文件..\eclipse-testng离线包\org.testng.eclipse_6.8.6.20130607_0745文件夹放到eclipse--》plugins目录下
4.重启eclipse
5.验证是否安装成功,file-->new-->other-->TestNg
第二种,在线安装(网上转载)
具体步骤如下:
1.Eclipse中点击Help->Install new software
2.点击Add 在Location输入 http://beust.com/eclipse
3.选中Testng版本,点击Next,按照提示安装,安装完之后重启Eclipse
4.新建JavaProject,右键BuildPath,添加testng-5.11-jdk15.jar和eclipse-testng.jar
5.新建一个sum类,用来计算两整数之和,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Java
package com.hpp;
public
class
sum {
private
int
no1;
private
int
no2;
private
int
mysum;
public
int
add(
int
no1,
int
no2){
mysum=no1+no2;
return
mysum;
}
}
|
6.再新建testng class
点击finish,代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import org.testng.annotations.Test;
import
static
org.testng.Assert.assertEquals;
import com.hpp.sum;
public
class
NewTest {
private
sum newSum=
new
sum();
@Test
public
void
f() {
int
mysum=newSum.add(1, 2);
assertEquals(3,mysum,
"Right"
);
}
}
|
testing,xml会自动配置好的,这里不用管
7.在testing.xml右键点击RunAs->Testng Suite,即可看到结果