1
我是CoffeeScript和Jasmine的初學者。我試圖測試如下一個簡單的類:我非常簡單的茉莉花測試失敗,消息'預期0爲1'。
class Counter
count: 0
constructor: ->
@count = 0
increment: ->
@count++
decrement: ->
@count--
reset: ->
@count = 0
root = exports ? this
root.Counter = Counter
於是,我寫了如下測試代碼:
describe("Counter", ->
counter = new Counter
it("shold have 0 as a count variable at first", ->
expect(counter.count).toBe(0)
)
describe('increment()', ->
it("should count up from 0 to 1", ->
expect(counter.increment()).toBe(1)
)
)
)
第二個測試總是失敗,該消息是以下:
Expected 0 to be 1.
謝謝你的好意。