1

コードを複製せず、単体テスト時にIoで例外がスローされたことを確認する慣用的な方法はありますか?

ここのところ:

threw := false
e := try(_method that should throw_)
e catch(Exception, threw = true)
if(threw not, fail("Should have thrown an Exception, but did not!"))
4

1 に答える 1

0

There is no built in expectation for that in Io's UnitTest. However, building a custom expectation isn't difficult at all, you could write this submit a pull request and use it just dandy.

Alternatively, if you're not hung up on using UnitTest, you can use my fork of iospec2 which has this expectation (and others) built in. My fork was done for my IoSpec project, so it's embedded with IoSpec. You'd be interested in the top-level iospec script and everything inside lib.

于 2012-03-17T02:57:00.953 に答える