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

P3P Web隐私

P3P Web隐私

克劳娜著、技桥译 / 克劳娜 / 清华大学出版社 / 2004-5 / 45.0

自万维网络中出现商业站点以来,基于Web的商业需求和用户的隐私权利之间就存在着不断的斗争。Web开发者们需要收集有关用户的信息,但是他们也需要表示出对用户隐私的尊重。因此隐私偏好工程平台,或者称之为P3P,就作为满足双方利益的技术应运而生了。 P3P由万维网协会研制,它为Web用户提供了对自己公开信息的更多的控制。支持P3P的Web站点可以为浏览者声明他们的隐私策略。支持P3P的浏览......一起来看看 《P3P Web隐私》 这本书的介绍吧!

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

在线压缩/解压 HTML 代码

html转js在线工具
html转js在线工具

html转js在线工具

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

正则表达式在线测试