TestNG

eclipse设置TestNG,下面的步骤必须遵循:

步骤1:下载TestNG的归档文件

下载 http://www.testng.org

OS 压缩文件名
Windows testng-6.8.jar
Linux testng-6.8.jar
Mac testng-6.8.jar

假设你上面复制的JAR文件到 C:\>TestNG 文件夹.

第二步:设置Eclipse环境

  • 打开 eclipse -> 右键单击项目,然后单击property > Build Path > Configure Build Path 并添加 testng-6.8.jar 在库中使用 Add External Jar 按钮.

Add testng-6.8.jar in liraries.
  • 我们假设你的eclipse 中 TestNG插件已经内置,如果不是,那么请使用更新站点获取最新版本:

    • 在你的 eclipse IDE, 选择 Help / Software updates / Find and Install.

    • 搜索新功能安装。

    • 新的远程站点。

    • For Eclipse 3.4 and above, enter http://beust.com/eclipse.

    • For Eclipse 3.3 and below, enter http://beust.com/eclipse1.

    • Make sure the check box next to URL is checked and click Next.

    • 然后Eclipse会引导帮您完成整个过程。

     

现在,你的eclipse已经可以使用 TestNG测试用例的开发做好准备。

步骤3:确认Eclipse已经安装TestNG

  • 在eclipse中创建一个项目TestNGProject

  • 创建一类MessageUtil在项目测试。

   
/*
* This class prints the given message on console.
*/
public class MessageUtil {

   private String message;

   //Constructor
   //@param message to be printed
   public MessageUtil(String message){
      this.message = message;
   }
      
   // prints the message
   public String printMessage(){
      System.out.println(message);
      return message;
   }   
} 
  • 在项目中创建一个测试类TestNGExample

   
import org.testng.Assert;
import org.testng.annotations.Test;

public class TestNGExample {
    String message = "Hello World";	
    MessageUtil messageUtil = new MessageUtil(message);

    @Test
    public void testPrintMessage() {	  
       Assert.assertEquals(message,messageUtil.printMessage());
   }
}

下面应该是项目结构:

Project Structure

最后,通过右击程序和TestNG的运行验证程序的输出。

验证结果。

TestNG result success.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值