eclipse中testng的配置和使用

Eclipse版本:
Eclipse Java EE IDE for Web Developers.
Version: Helios Release

Testng版本:
5.13

步骤

1.Eclipse中点击Help->Install new software
2.点击Add    在Location输入 http://beust.com/eclipse

下载testng

3.选中Testng版本,点击Next,按照提示安装,安装完之后重启Eclipse
4.新建JavaProject,右键BuildPath,添加testng-5.11-jdk15.jar和eclipse-testng.jar
5.新建一个sum类,用来计算两整数之和,代码如下:

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

新建class

点击finish,代码如下

package com.test;

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,即可看到结果

运行结果

3 Responses

  1. […] eclipse中testng的配置和使用 Recent Comments韩小麦 on Hello world!韩小麦 on Hello world!韩小麦 on About RSS Copyright © 2010 Pentax k-x All rights reserved. Amazing Grace theme by Vladimir Prelovac […]

  2. 小虎说道:

    博主你好,请问一下你文章中说的testing.xml是要提前部署的是吧?