1

I'm having some trouble making Kotlin and EasyMock play nice with each other.

I have a test containing something like this:

expect(foo.createClassLoader(aryEq(arrayOf("foo.jar")))).andReturn(classLoader)

(where foo is a mock object)

However, this throws java.lang.IllegalStateException: aryEq(arrayOf("foo.jar")) must not be null because my createClassLoader method doesn't accept a nullable array, and for some reason EasyMock.aryEq returns null:

public static <T> T[] aryEq(final T[] value) {
    reportMatcher(new ArrayEquals(value));
    return null;
}

Is there any way out of this?

Max
  • 4,882
  • 2
  • 29
  • 43
  • Possible duplicate of [Is it possible to use Mockito in Kotlin?](http://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin) – Max Dec 08 '16 at 18:10
  • `createClassLoader` should be a method from a mock. It doesn't seem to be the case here – Henri Dec 10 '16 at 18:45
  • Sorry, it actually is. I'll change it to `foo.createClassLoader` to make it slightly clearer. – Max Dec 10 '16 at 19:03
  • Ok. In Java, this would occur if the method was final or static. Or not a mock, or a partial mock with this method unmocked. How do you create the mock? – Henri Dec 12 '16 at 02:57
  • 1
    Yes @Henri, opening the mocked method in kotlin just worked great. Thanks (though error messages could be a little more clear ;) – Snicolas Jun 27 '19 at 18:12
  • What was the full stacktrace? Is it coming from EasyMock? – Henri Jun 30 '19 at 04:05

0 Answers0