testNG helloWorld
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的更多相关文章
- Self20171218_Eclipse+TestNg HelloWorld
作为一个经典的入门例子,这里展示如何开始使用TestNG单元测试框架. 使用的工具 : TestNG 6.8.7 Maven 3 Eclipse IDE TestNG下载并安装 从这里 http:// ...
- ant+jenkins+testng+selenium集成环境搭建
一.前序工作 下载ant:http://ant.apache.org/bindownload.cgi 下载jenkins:http://jenkins-ci.org/ 下载testng:http:// ...
- Selenium2(webdriver)入门之TestNG的使用
一.在Eclipse中安装TestNG 1.打开eclipse-->help-->Install New Software-->Add,输入Name和Location后,点击OK. ...
- Selenium WebDriver TestNg Maven Eclipse java 简单实例
环境准备 前提条件Eclipse 已经安装过 TestNg ,Maven 插件 新建一个普通的java项目 点击右键 configure->convert to Maven Project 之后 ...
- Spring学习笔记2:Spring HelloWorld
1:IntelliJ新建Maven工程 2:pom文件加入Spring依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" ...
- JAVA+SELENIUM+MAVEN+TESTNG框架(二)新建项目
1.新建maven项目 2.下载selenium的jar包,放入maven依赖库中 3.新增testng依赖库,build path->add libirary->testng 4.查看自 ...
- Selenium2(webdriver)入门之TestNG的安装与简单使用
上一篇已经搭建好了Eclipse+selenium2的环境,这一篇主要记录下TestNG的使用. 一.在Eclipse中安装TestNG 1.打开eclipse-->help-->Inst ...
- testNG断言
https://junit.org/junit4/javadoc/latest/org/junit/Assert.html#assertThat 断言:Hamcrest - Matchers 对象: ...
- TestNG入门到...
目录 一.概述 二.@Test注解常用参数 三.测试中常用的断言(assert) 四.TestNG常用注解及使用 五.配置文件xml常用标签 六.参数传递 七.测试报告 一.概述 1.TestNG是一 ...
随机推荐
- openssl 自己制作ssl证书:自己签发免费ssl证书,为nginx生成自签名ssl证书
server { listen 80; listen 443 ssl; server_name ~^((cloud)|(demo-cloud)|(demo2-cloud)|(approval1))(( ...
- Jav获取文件的MD5码,比较两个文件内容是否相同
Jav获取文件的MD5码,比较两个文件内容是否相同 代码: System.out.println(DigestUtils.md5Hex(new FileInputStream(new File(&qu ...
- scrapy爬虫案例:问政平台
问政平台 http://wz.sun0769.com/index.php/question/questionType?type=4 爬取投诉帖子的编号.帖子的url.帖子的标题,和帖子里的内容. it ...
- FileHelper-文件操作工具
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io ...
- [转]Oringin 2016 安装教程
觉得有用的话,欢迎一起讨论相互学习~Follow Me 原文ll链接 http://www.downza.cn/soft/282296.html 打开setup.exe 一路Next和Yes,任意输入 ...
- c#内存泄漏分析
背景 给客户开发了一个WPF应用,每隔一段时间就会很卡,推测是内存泄漏引起.需要监测内存使用情况. 使用的工具 Ants Memory Profiler 百度网盘下载地址 使用教程 入门使用 参考文档 ...
- [转载]ROS开发环境之Qt Creator
ROS开发环境之Qt Creator(http://my.phirobot.com/blog/2013-12-ros_ide_qtcreator.html) Created at: 2013-12-2 ...
- Windows下安装gcc环境
安装GCC环境 https://gcc.gnu.org/ 点进去后 然后 然后 点击 再点击 点击 (啊,这是跳了多少个页面) 开始下载了.完成之后打开:(自动执行的) 弹出 点击OK,弹出个窗口,让 ...
- matlab 双坐标折线图画法
%%各时段电量需求 clc close all clear all cost_gd = [2200 1800 3800 4600]; cost_bj = [2.7 2.2 1.8 3.6]; cost ...
- 网站登录注册-Session 和token的总结
1.为什么要使用session 因为http本身是无状态协议,无法确定你的本次请求和上次请求是不是你发送的.如果要进行类似论坛登陆相关的操作,就实现不了了. 2.Session 生成方式 浏览器第一次 ...