New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot mock Exceptions/ Throwable with @Mocked annotation #457

Closed
Sebsen opened this Issue Sep 14, 2017 · 2 comments

Comments

3 participants
@Sebsen

Sebsen commented Sep 14, 2017

Please provide the following information:

  • Version of JMockit that was used: Update from Version 1.30 to Version 1.34

  • Description of the problem:
    Since the update from JMockit version 1.30 to version 1.34 we're not able to mock any type of exception (standard JDK type neither custom created types) with JMockit's @mock annotation - bug or feature?

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).

Regards
Sebsen

@Sebsen Sebsen changed the title from Cannot mock Exceptions/ Throwable with @Mock annotation to Cannot mock Exceptions/ Throwable with @Mocked annotation Sep 14, 2017

@rliesenfeld rliesenfeld self-assigned this Sep 15, 2017

@rliesenfeld rliesenfeld added the bug label Sep 15, 2017

@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Sep 15, 2017

Member

Indeed, the outcome from @Mocked SomeException should be the same as @Injectable SomeException.

Thanks for reporting the bug!

Member

rliesenfeld commented Sep 15, 2017

Indeed, the outcome from @Mocked SomeException should be the same as @Injectable SomeException.

Thanks for reporting the bug!

@novaterata

This comment has been minimized.

Show comment
Hide comment
@novaterata

novaterata Oct 6, 2017

I still can't mock any Exception in 1.35 (but could in 1.33) I'm unclear on the status of this issue.

novaterata commented Oct 6, 2017

I still can't mock any Exception in 1.35 (but could in 1.33) I'm unclear on the status of this issue.

@jmockit jmockit locked and limited conversation to collaborators Oct 11, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.