I googled little bit and it seems for me that it's possible. But when I tried like this:
class Calc {
def sum(first: Int, second: Int) = {
first + second
}
}
And "test" class:
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 class mockit.Invocations from class com.kvg.client.CalcTest$$anon$1 at com.kvg.client.CalcTest$$anon$1.(CalcTest.scala:11) at com.kvg.client.CalcTest.testSum(CalcTest.scala:9) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Can JMockit work with with scala? And if it can what am I doing wrong?