Java GroovyTestCase中的expect子句
当我在archiveUtility对象上调用process方法时,它抛出一个IllegalArgumentException,但是我的测试仍然失败,即使我已经声明测试预期IllegalArgumentException。这是一个groovyTestCase。我不明白为什么会这样?有什么想法吗 您是否尝试过在GroovyTestCase中添加.class(预期=IllegalArgumentException.class)?您可以使用。试试这个:Java GroovyTestCase中的expect子句,java,groovy,junit,Java,Groovy,Junit,当我在archiveUtility对象上调用process方法时,它抛出一个IllegalArgumentException,但是我的测试仍然失败,即使我已经声明测试预期IllegalArgumentException。这是一个groovyTestCase。我不明白为什么会这样?有什么想法吗 您是否尝试过在GroovyTestCase中添加.class(预期=IllegalArgumentException.class)?您可以使用。试试这个: @Test(expected=IllegalArg
@Test(expected=IllegalArgumentException)
void testNullArgument()
{
archiveUtility.process(lstFileName, "", workflowId)
}
您是如何运行这些测试用例的?您使用的是哪个版本的groovy?
void testNullArgument()
{
shouldFail(IllegalArgumentException)
{
archiveUtility.process(lstFileName, "", workflowId)
}
}