31
テスト用ライブラリ power-assert 和田 卓人 (a.k.a id:t-wada or @t_wada) May 29, 2014 @ JSオジサン #2

テスト用ライブラリ power-assert

Embed Size (px)

DESCRIPTION

テスト用ライブラリ power-assert 2014/05/29 @ JSオジサン#2

Citation preview

Page 1: テスト用ライブラリ power-assert

テスト用ライブラリ power-assert

和田 卓人 (a.k.a id:t-wada or @t_wada)May 29, 2014 @ JSオジサン #2

Page 2: テスト用ライブラリ power-assert

和田 卓人id: t-wada@t_wadagithub: twada

Page 3: テスト用ライブラリ power-assert

テスト書いてますか?

http://twitpic.com/dzgwk8

Page 4: テスト用ライブラリ power-assert

沢山あって難しそう...

Page 6: テスト用ライブラリ power-assert

覚えることも多そう...

Page 8: テスト用ライブラリ power-assert

33メソッド!?

http://azu.github.io/slide/sakurajs/power-assert.html#/3azu さん調べ

Page 9: テスト用ライブラリ power-assert

アサーションライブラリの不毛な軍拡競争は何かがおかしい...

Page 10: テスト用ライブラリ power-assert

そもそもassert の情報量が多ければいいのでは?

Page 11: テスト用ライブラリ power-assert

power-asserthttps://github.com/twada/power-assert

Page 12: テスト用ライブラリ power-assert

デモ

Page 13: テスト用ライブラリ power-assert

assert(typeof item.id === 'strong') | | | | | | | false | | "hoge" | Item{id:"hoge"} "string"

--- [string] 'strong'+++ [string] typeof item.id@@ -1,6 +1,6 @@ str-o+i ng

テスト失敗がこのように出力されます

Page 14: テスト用ライブラリ power-assert

良いインタフェースとは次の2つの条件を満たすインタフェース

•正しく使用する方が操作ミスをするより簡単

•誤った使い方をすることが困難

きのこ53: 正しい使い方を簡単に、誤った使い方を困難に

Page 15: テスト用ライブラリ power-assert

7±2"The Magical Number Seven, Plus or Minus Two: Some Limits on Our Capacity for Processing Information"

Page 16: テスト用ライブラリ power-assert

assert(actual)

assert.deepEqual(actual,expected)

assert.notDeepEqual(actual,expected)

3つ覚えればテストは書ける

Page 17: テスト用ライブラリ power-assert

覚えることは少なく、かつテスト失敗時の情報は多く

何もなければ黙るのみ落ちるときはやかましく

Page 18: テスト用ライブラリ power-assert

テストライブラリの競争は語彙の繁栄と暴走を招いた

power-assert はコードの復権

Page 19: テスト用ライブラリ power-assert

テスト書きましょう!

Page 20: テスト用ライブラリ power-assert

使い方

Page 23: テスト用ライブラリ power-assert

新機能

Page 24: テスト用ライブラリ power-assert

built withbrowserify

Page 25: テスト用ライブラリ power-assert

依存ライブラリを同梱したバンドルを配布

Page 26: テスト用ライブラリ power-assert

BinaryExpressionstring diff

Page 27: テスト用ライブラリ power-assert

assert(typeof item.id === 'strong') | | | | | | | false | | "hoge" | Item{id:"hoge"} "string"

--- [string] 'strong'+++ [string] typeof item.id@@ -1,6 +1,6 @@ str-o+i ng

BinaryExpression の右辺左辺を diff

Page 28: テスト用ライブラリ power-assert

デバッガ連携

Page 29: テスト用ライブラリ power-assert

SourceMap によるデバッガ連携

Page 30: テスト用ライブラリ power-assert

Special Thanks to

@azu_re さん@vvakame さん

Page 31: テスト用ライブラリ power-assert

ご清聴ありがとうございました

power-asserthttps://github.com/twada/power-assert