Source code:
def "show problem"() {
given:
SampleFactory sf = Mock()
when:
sf.makeObject("b", null);
then:
0 * sf.makeObject("a", _);
}
private interface SampleFactory {
void makeObject(String id, Integer[] arrayInt)
}
Exception thrown:
java.lang.NullPointerException
at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
at java.util.Arrays.asList(Arrays.java:3343)
at org.spockframework.mock.PositionalArgumentListConstraint.expandVarArgs(PositionalArgumentListConstraint.java:57)
Reason:
PositionalArgumentListConstraint.java line 57
expanded.addAll(Arrays.asList((Object[]) CollectionUtil.getLastElement(args)));
1. Because the last element of method should be an array, Spock checks for Var
Arg Syntax
2. The actual value for last element is null. Hence, Arrays.asList fails
What version of Spock and Groovy are you using?
Spock 0.6 Groovy 1.7.10
Original issue reported on code.google.com by cyprush...@gmail.com on 3 Apr 2012 at 12:40
Original issue reported on code.google.com by
cyprush...@gmail.com
on 3 Apr 2012 at 12:40