测试使用Nimble在Quick中引发错误的方法时出错

Roc*_*den 5 swift quick-nimble

我在测试一个抛出异常的方法时让Nimble匹配器正确无误.根据文档,它应该很简单.我只需要这样的期望

expect( try somethingThatThrows() ).toNot( throwError() ) 
Run Code Online (Sandbox Code Playgroud)

但是对于Swift 3和Xcode 8.2,我得到了一个编译器编辑器.这是上下文.

describe("Using RealmDatasource") {

   let datastore = RealmDatasource() as Datasource

       it("can retrieve an object") {

           expect( try datastore.getCurrentObject() ).to( throwError() )

       }

}
Run Code Online (Sandbox Code Playgroud)

我在'it'声明行上收到以下错误

Invalid conversion from throwing function of type '() -> () throws to non-throwing function of type '() -> ()'
Run Code Online (Sandbox Code Playgroud)

Fis*_*man 8

尝试使用带括号的expect {}

expect { try datastore.getCurrentObject() }.to( throwError() )

应该工作