1. 新建maven工程。File -> New -> Project -> Maven,不选Create from archetype,直接点击“Next”。GroupId和ArtifactId填TestHelloWorld。点击确认,完成新建。

2. src -> main -> java下新建java文件,内容如下:

public class RandomEmailGenerator {

    public String emailGenerator(){
return "Have generate an email";
}
}

3. src -> test -> java下新建java文件,内容如下:

import org.testng.Assert;
import org.testng.annotations.Test; public class TestHelloWorld { @Test
public void testEmailGenerator(){
RandomEmailGenerator randomEmailGenerator = new RandomEmailGenerator();
String email = randomEmailGenerator.emailGenerator(); Assert.assertEquals(email, "Have generate an email");
}
}

4. pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>TestHelloWorld</groupId>
<artifactId>TestHelloWorld</artifactId>
<version>1.0-SNAPSHOT</version> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies> </project>

5. 配置工程。

选择TestNG,class里选择TestHellWorld.java文件。

6. 运行

点击unname旁边的三角符号,将运行testNG测试用例。运行结果如下。

testNG helloWorld的更多相关文章

  1. Self20171218_Eclipse+TestNg HelloWorld

    作为一个经典的入门例子,这里展示如何开始使用TestNG单元测试框架. 使用的工具 : TestNG 6.8.7 Maven 3 Eclipse IDE TestNG下载并安装 从这里 http:// ...

  2. ant+jenkins+testng+selenium集成环境搭建

    一.前序工作 下载ant:http://ant.apache.org/bindownload.cgi 下载jenkins:http://jenkins-ci.org/ 下载testng:http:// ...

  3. Selenium2(webdriver)入门之TestNG的使用

    一.在Eclipse中安装TestNG 1.打开eclipse-->help-->Install New Software-->Add,输入Name和Location后,点击OK. ...

  4. Selenium WebDriver TestNg Maven Eclipse java 简单实例

    环境准备 前提条件Eclipse 已经安装过 TestNg ,Maven 插件 新建一个普通的java项目 点击右键 configure->convert to Maven Project 之后 ...

  5. Spring学习笔记2:Spring HelloWorld

    1:IntelliJ新建Maven工程 2:pom文件加入Spring依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" ...

  6. JAVA+SELENIUM+MAVEN+TESTNG框架(二)新建项目

    1.新建maven项目 2.下载selenium的jar包,放入maven依赖库中 3.新增testng依赖库,build path->add libirary->testng 4.查看自 ...

  7. Selenium2(webdriver)入门之TestNG的安装与简单使用

    上一篇已经搭建好了Eclipse+selenium2的环境,这一篇主要记录下TestNG的使用. 一.在Eclipse中安装TestNG 1.打开eclipse-->help-->Inst ...

  8. testNG断言

    https://junit.org/junit4/javadoc/latest/org/junit/Assert.html#assertThat 断言:Hamcrest - Matchers 对象: ...

  9. TestNG入门到...

    目录 一.概述 二.@Test注解常用参数 三.测试中常用的断言(assert) 四.TestNG常用注解及使用 五.配置文件xml常用标签 六.参数传递 七.测试报告 一.概述 1.TestNG是一 ...

随机推荐

  1. Curator框架实现ZooKeeper分布式锁

    排他锁(X) 这里主要讲讲分布式锁中的排他锁.排他锁(Exclusive Locks,简称X锁),又称为写锁或独占锁,是一种基本的锁类型.如果事务T1对数据对象O1加上了排他锁,那么在整个加锁期间,只 ...

  2. boot2docker

    boot2docker 简介 boot2docker是解决非linux系统下运行Docker容器不方便的工具 官方介绍 Boot2Docker是在Windows操作系统上运行Docker的唯一方法,现 ...

  3. 泡泡一分钟:Optimal Trajectory Generation for Quadrotor Teach-And-Repeat

    张宁 Optimal Trajectory Generation for Quadrotor Teach-And-Repeat链接:https://pan.baidu.com/s/1x0CmuOXiL ...

  4. mac环境更新node版本

    执行命令: 清除node的cache(清除node的缓存) sudo npm cache clean -f 安装"n"版本管理工具,管理node(没有错,就是n) sudo npm ...

  5. bladex-boot推送harbor出错

    出错信息: Building image harbor.zhangshuiqing.com:8081/blade/Bladex-boot:2.2.1.release十二月 13, 2019 11:22 ...

  6. LODOP常见问题连接(含常见小问答博文)

    问答大全 纸张打印机 注册 table表格 clodop测试地址 字体 超文本 行间距.字间距 clodop回调函数 条码 页眉页脚 SET……STYLEA 水平居中 简短排查 提示报错 慢进度条 套 ...

  7. 基础自动化部署搭建过程【Jenkins】

    测试环境搭建 为了快速搭建一套PHP测试环境我决定用laradock了,虽然文件很多,但是里面封装的东西也是比较全的,后期开发不知道会用到什么技术,就决定先用这个,随时可以启动用得到的服务.larad ...

  8. 【jquery】【ztree】节点添加自定义按钮、编辑和删除事件改成自己定义事件

    setting添加 edit: { drag: { isCopy: false, isMove: true }, enable: true,//设置是否处于编辑状态 showRemoveBtn: sh ...

  9. 十分钟读懂JavaScript原型和原型链

    原型(prototype)这个词来自拉丁文的词proto,意谓“最初的”,意义是形式或模型.在JavaScript中,原型的探索也有很多有趣的地方,接下来跟随我的脚步去看看吧. 原型对象释义 每一个构 ...

  10. Java reactor响应式编程

    转载自:https://www.cnblogs.com/lixinjie/p/a-reactive-streams-on-jvm-is-reactor.html 响应式编程 作为响应式编程方向上的第一 ...