- Version of JMockit that was used: 1.21
- Description of the problem or enhancement request:
One of our tests keeps failing occasionally on the CI build with the exception as below. We are running our tests using maven-surefire-plugin with forkMode set to always. Tests are not running in parallel.
java.lang.IllegalStateException: Not in the recording phase
at com.dummy.DummyTest$1.<init>(DummyTest.java:67)
at com.dummyDummyTest.setup(DummyTest.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:119)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:74)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Its not reproducible on local as i mentioned it happens occasionally. The class tries to test the partially mocked class. The method where it fails looks like below
public class DummyTest {
@Mocked Context ctx;
ClassToBeTested cls;
@Before
public void setup() throws QBOException {
cls = new SubClassToBeTested();
new NonStrictExpectations() {
{
Context.getAuthenticatedContext();
result = ctx; //it fails here occasionally line no: 67
}
{
ctx.getSomeMethod;
result = "someString";
}
};
.........
}
The above test definitely need some refactoring but was wondering why does it fail occasionally and not always. I noticed similar issue being reported by someone at https://groups.google.com/forum/#!topic/jmockit-users/LknMgexD_jE
One of our tests keeps failing occasionally on the CI build with the exception as below. We are running our tests using maven-surefire-plugin with forkMode set to always. Tests are not running in parallel.
Its not reproducible on local as i mentioned it happens occasionally. The class tries to test the partially mocked class. The method where it fails looks like below
The above test definitely need some refactoring but was wondering why does it fail occasionally and not always. I noticed similar issue being reported by someone at https://groups.google.com/forum/#!topic/jmockit-users/LknMgexD_jE