Can JMockit work with scala?

I ruined a little, and it seems to me that this is possible. But when I tried like this:

class Calc { def sum(first: Int, second: Int) = { first + second } } 

And the class "test":

 class CalcTest { @Test def testSum(@Mocked test: Calc) { new NonStrictExpectations() {{ test.sum(2, 3) times = 1 result = Int.box(5) }} Assert.assertEquals(5, test.sum(2, 3)) } } 

I have an exception:

java.lang.IllegalAccessError: tried to access the mockit.Invocations class from com.kvg.client.CalcTest $$ anon $ 1 at com.kvg.client.CalcTest $$ anon $ 1 class. (CalcTest.scala: 11) at com.kvg.client.CalcTest.testSum (CalcTest.scala: 9) at sun.reflect.NativeMethodAccessorImpl.invoke0 (native method) in sun.reflect.NativeMethodAccessorImpl.invoke0 (native method) in com .intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs (JUnit4IdeaTestRunner.java:77) in com.intellij.rt.execution.junit.JUnitStarter.prepareStrej.itit.jt.jt.jit.jt comjava (JUnitStarter.java:63) at com.intellij.rt.execution.application.AppMain.main (AppMain.java:120)

Can JMockit work with scala? And if he can, what am I doing wrong?

+7
scala junit jmockit
source share
1 answer

JMockit does not support Scala or any language other than Java in the JVM

https://github.com/jmockit/jmockit1/pull/358

Finally, there have already been requests in the past to add support for other JVM languages. I remember Scala (ScalaMock), Extend and Kotlin. If Groovy support has been approved, how do I opt out of supporting other languages? And bearing in mind that the JMockit project was never intended to support anything other than the JVM (i.e., not like Dalvik) and the Java language.

0
source share

All Articles