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?
scala junit jmockit
Moses
source share