Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Cannot mock Exceptions/ Throwable with @Mocked annotation #457
Please provide the following information:
From eclipse JUnit tests stop to run cause an StackOverflowError claiming a NoClassDefFoundError/ ClassNotFoundException when an exception type field is annotated with @Mocked annotation. From ANT execution crashes with an "JVM exited abnormally" error. @tested on the other hand works fine though.
When an exception type is mocked with @Mocked annotation as method parameter the test just fails directly with the appropriate failure message: "java.lang.IllegalArgumentException: Class java.lang.Throwable is not mockable". Even though it's a standard JDK exception type or a custom one.
In JMockit version 1.32 the mocking of exception types worked fine, so I think the behaviour changed with the release of version 1.33 (which became extended features with the @tested annotation).