scalaTest的使用
来源:互联网 发布:linux ps命令中括号 编辑:程序博客网 时间:2024/05/22 11:51
配置
修改pom.xml
,添加以下内容
<!--依赖--><dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_2.11</artifactId> <version>3.0.0</version> <scope>test</scope></dependency><!--插件--><plugin> <groupId>org.scalatest</groupId> <artifactId>scalatest-maven-plugin</artifactId> <version>1.0</version> <configuration> <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> <junitxml>.</junitxml> <filereports>WDF TestSuite.txt</filereports> </configuration> <executions> <execution> <id>test</id> <goals> <goal>test</goal> </goals> </execution> </executions></plugin><!--测试代码和文件--><testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>
一个简单的例子
import org.scalatest.FunSuiteclass SetFuncSuite extends FunSuite { //差集 test("Test difference") { val a = Set("a", "b", "a", "c") val b = Set("b", "d") assert(a -- b === Set("a", "c")) } //交集 test("Test intersection") { val a = Set("a", "b", "a", "c") val b = Set("b", "d") assert(a.intersect(b) === Set("b")) } //并集 test("Test union") { val a = Set("a", "b", "a", "c") val b = Set("b", "d") assert(a ++ b === Set("a", "b", "c", "d")) }}
在IDEA里直接运行
程序打包时会自动进行测试
mvn clean package
如果测试通过,
如果测试不通过,则会打包失败,比如
test("Test difference") { val a = Set("a", "b", "a", "c") val b = Set("b", "d") //应该等于Set("a","b") assert(a -- b === Set("b", "c")) }
0 0
- scalaTest的使用
- ScalaTest
- scala学习14之scalatest中的intercept使用
- ScalaTest 1.0发布,开源的Java,Scala测试框架
- scalatest初探
- Scala学习11之在eclipse下使用scalatest插件对scala文件进行测试
- scalatest - install and use scalatest with eclipse
- ScalaTest测试框架
- ScalaTest测试框架
- ScalaTest User Guide
- Scala学习10之在eclipse下使用maven对spark和adam中的scalatest进行测试
- maven 运行scalatest以及elastic search 自定义id
- GUID使用的使用
- ${}的使用
- 的使用
- @[],@()的使用
- ->的使用
- +、-、*、/、%的使用
- cxf无法处理类型解决方法
- 关系模型
- PAT 1037Find Coins (25)(dp子序列)
- LeetCode 209 Minimum Size Subarray Sum
- 给自己一个新起点
- scalaTest的使用
- Hibernate 框架学习整理(一)
- 如何在Mac OS X上安装 Ruby运行环境
- web service 权限控制以及cxf拦截器
- mysql 表的操作
- asprin
- 中文论文模板
- java List、Set、Map集合遍历
- Mac系统下Cocoapods安装使用方法