Swift 的 BDD 测试框架 Swiftest

码农软件 · 软件分类 · 单元测试工具 · 2019-11-18 15:59:22

软件介绍

Swiftest 是 Swift 编程语言一个 BDD 风格的规范框架。

示例代码:

import Swiftest

// create a class that inherits from SwiftestSuite (it's just NSObject)
// and define the 'spec' member property of that class using `describe`
// be sure to use `let` and not `var` here!

class SampleSpec : SwiftestSuite {
  let spec = describe("Swiftest") {
    it("adds 1 + 1!") {
      expect(1 + 1).toEqual(2)
    }

    it("knows true from false!") {
      expect(true).toBeTrue()
      expect(true).not().toBeFalse()
    }

    example("comparing letters of the alphabet!") {
      expect("abc").toEqual("abc")
    }

    it("knows what stuff is NOT other stuff!") {
      expect(2 + 2).not().toEqual(5)
    }

    describe("arrays!") {
      example("special assertions for array types!") {
        expect([1, 2, 3]).toEqual([1, 2, 3])

        expect([1, 2, 3]).toContain(1)
        expect([1, 2, 3]).toContain(1, 3)
      }
    }

    it("does nifty stuff with closures") {
      var a = 0

      expect({ a += 1 }).toChange({ a }).to(1)
      expect({ a += 1 }).toChange({ a }).from(1).to(2)
      expect({ a += 2 }).toChange({ a }).by(2)
    }

    example("dictionaries have special assertions too!") {
      expect([ "key" : "val" ]).toEqual([ "key" : "val"])
      expect([ "key" : "val" ]).toHaveKey("key")
      expect([ "key" : "val" ]).toHaveValue("val")
    }

    example("your own classes!") {
      // Person is a class that implements Comparable
      let person1 = Person(name: "Bob")
      let person2 = Person(name: "Alice")

      expect(person1).not().toEqual(person2)
    }
  }
}

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

智能家居:商业模式+案例分析+应用实战

智能家居:商业模式+案例分析+应用实战

陈国嘉 / 人民邮电出版社 / 2016-4 / 49.80元

作为万物互联的关键一环,智能家居的出现和普及已经势不可当,以移动互联网为核心的新技术正在重构智能家居。只有成为智能家居行业的先行者,才能抢占“风口”。 《智能家居:商业模式+案例分析+应用实战》紧扣“智能家居”,从3个方面进行专业、深层次的讲解。首要方面是基础篇,从智能家居的发展现状、产业链、商业分析、抢占入口等方面进行阐述,让读者对智能家居有个初步的认识;第二个方面是技术篇,从智能家居的控......一起来看看 《智能家居:商业模式+案例分析+应用实战》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试