My test requires that one of the dependent mocked methods returns an enum. However, this causes JMockit to throw a ClassCastException.
public class MyTest {
@Mocked Parameters params;
@Test
public void test() {
new NonStrictExpectation() {
{
params.getPlatform(); result = Platform.DESKTOP;
}
};
MyClass myClass = new MyClass(params);
String str = myClass.run();
assertNotNull(str);
}
}
Running the test throws:
java.lang.ClassCastException: java.lang.String cannot be cast to com.mypackage.Platform
How do I properly return an enum?