1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        SwiftestSwift 的 BDD 測試框架

        聯(lián)合創(chuàng)作 · 2023-10-01 15:16

        Swiftest 是 Swift 編程語言一個(gè) BDD 風(fēng)格的規(guī)范框架。

        示例代碼:

        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)
            }
          }
        }
        瀏覽 10
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            黄色A级大片 | 国产性在线观看 | 成人网站在线免费观看 | 久久一区二区三区在线 | 91黄片免费看 | 性生活免费视频 | 波多野吉衣三级 | 少妇高潮69xx | 神马久久午夜 | 97视频一区二区三区在线观看 |