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://codercto.com/soft/d/19373.html

Web Design for ROI

Web Design for ROI

Lance Loveday、Sandra Niehaus / New Riders Press / 2007-10-27 / USD 39.99

Your web site is a business--design it like one. Billions of dollars in spending decisions are influenced by web sites. So why aren't businesses laser-focused on designing their sites to maximize thei......一起来看看 《Web Design for ROI》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具