Java 测试规范框架 Spek

码农软件 · 软件分类 · 单元测试工具 · 2019-11-18 17:43:28

软件介绍

Spek 是 JetBrains 开发的 JVM 的一个规范框架,通过优雅的 DSL 来清晰描述你的代码规范,主要用于 Kotlin 语言的测试。

一般的测试代码:

@Test
public void testCalculateTaxRate() {
    TaxRateCalculator calculator = new TaxRateCalculator();
    Int value = calculator.calculateRate(200, 10);
    assertEquals(300,value);
}

使用 Spek 的测试代码:

class TaxCalculatorSpecs: Spek() {{

    given("Tax rate calculator with default locale settings") {
        val taxRateCalculator = TaxRateCalculator()
        on("calculating the rate for an income of 200 and an average change of 10 per semester") {
            val value = taxRateCalculator.calculateRate(200, 10)
            it("should result in a value of 300") {
                assertEquals(300, value)
            }
        }
    }
}}

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

The Little MLer

The Little MLer

Matthias Felleisen、Daniel P. Friedman、Duane Bibby、Robin Milner / The MIT Press / 1998-2-19 / USD 34.00

The book, written in the style of The Little Schemer, introduces instructors, students, and practicioners to type-directed functional programming. It covers basic types, quickly moves into datatypes, ......一起来看看 《The Little MLer》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换