Rails:Mocha gem如何测试异常

时间:2017-11-10 01:33:14

标签: ruby-on-rails mocha minitest

以下是我的代码

开始

Test.testcode

救援

我想测试我的异常处理逻辑以及我正在做的事情     Test.stubs(:testcode).raises(Exception,"jkkh")但我的测试没有通过。我在测试用例中遇到错误

<?xml version="1.0" encoding="UTF-8"?>
<testsuite time="3.211" assertions="0" tests="1" errors="1" failures="0" skipped="0" name="OpnavPreCalculationsControllerTest">
<testcase time="3.211" assertions="0" name="test_should" classname="OpnavPreCalculationsControllerTest">
<error message="Exception: jkkh..." type="test_should"> Failure: test_should(OpnavPreCalculationsControllerTest) [C:/jruby-1.7.16/lib/ruby/gems/shared/gems/mocha-1.1.0/lib/mocha/exception_raiser.rb:11]: Exception: jkkh </error>
</testcase>
</testsuite>

0 个答案:

没有答案