Java与Scala测试 ScalaTest

码农软件 · 软件分类 · 单元测试工具 · 2019-11-20 06:11:27

软件介绍

Scala Test 是一个开源测试框架。ScalaTest旨在令测试更加高效。其开发者Bill Venners(Artima主编,同时也是资深的程序员)这样描述到:

“ScalaTest 1.0是比JUnit和TestNG更加高阶的测试编写工具,这个Scala应用在JVM上运行,可以测试Scala以及Java代码。除了与JUnit 和TestNG的深层集成,同时还支持Ant任务,与maven集成,并包括了流行的Java mocking框架JMock、EasyMock以及Mockito的语法增强。通过JUnit集成,ScalaTest可以轻松地在Eclipse、 NetBeans以及IntelliJ IDEA等IDE,以及Infinitest等生产工具中使用。

测试代码:

import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers

class StackSpec extends FlatSpec with ShouldMatchers {

"A Stack" should "pop values in last-in-first-out order" in {
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
stack.pop() should equal (2)
stack.pop() should equal (1)
}

it should "throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[String]
evaluating { emptyStack.pop() } should produce [NoSuchElementException]
}
}

在线API文档:http://www.ostools.net/apidocs/apidoc?api=scalatest-1.7.2

本文地址:https://www.codercto.com/soft/d/19373.html

Charlotte's Web

Charlotte's Web

E. B. White / Puffin Classics / 2010-6-3 / GBP 6.99

This is the story of a little girl named Fern who loved a little pig named Wilbur and of Wilbur's dear friend, Charlotte A. Cavatica, a beautiful large grey spider. With the unlikely help of Templeton......一起来看看 《Charlotte's Web》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具