-
Notifications
You must be signed in to change notification settings - Fork 2
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
Overriding final of AtomicBoolean type doesn't work #247
Comments
that's a bit tricky. First of all the syntax is wrong. You either need to write
or
Other than that you can not get a value from a mock in the expect block.
But even if you would this your specification AtomicBoolean can currently. Classes must not be loaded before trying to transform them. Unfortunately AtomicBoolean is loaded during startup by ByteBuddy itself before the mock transformation can kick in. Regards |
Thanks for the prompt reply. So does this mean that mocking finals in the Java standard library is basically not supported by this plugin? Also, in your reply you suggested that this "might change in the future" - do you have a link to a feature request or future improvement that I could watch for progress updates on this plan? |
It's a little bit trickier than that. Classes that are loaded before the agent starts can not be altered. So the restriction applies to some Java standard library classes but not all. Only classes used by ByteBuddy, the startup process of JUnit and maybe the built system. Let's just put a feature label on this issue. But to be precise I don't see how to see how to implement this feature at the moment. I'm currently working on a mechanism that mocked classes are detected automatically rather than using the |
I have been experimenting with Spock lately as a potential replacement for JUnit / Mockito in some unit tests I am working on and have been struggling with mocking of classes that have final fields and methods. I was hoping this Spock plugin might address at least some of my problems, but I can not get a very simple POC Spock test to work properly. The simplest example test I've found is shown below:
I am quite new to Java and Spock so I am wondering if I am just doing something fundamentally wrong here, or if this is perhaps a bug with this plugin?
The text was updated successfully, but these errors were encountered: