jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
465 stars 240 forks source link

"No constructor in tested class that can be satisfied" if you have a @Injectable enum #173

Closed The-Alchemist closed 9 years ago

The-Alchemist commented 9 years ago
Caused by: java.lang.IllegalArgumentException: No constructor in tested class that can be satisfied by available injectables
.....
disregarded because parameter names are not available

I'm seeing this super strange error with a class that has a large constructor (8 params), and the last one is an enum. Based on some breakpoints I set, looks like parameter names are available.

I don't have a reproducible test case (yet), but I can see that in mockit.internal.state.ParameterNames.registerName(), parameterNames ends up looking like [db, httpClient, someAccount, clock, minimumSleepDurationInMs, testModeSettingValue, null]. That null is where the name of my enum variable should go.

In MethodOrConstructorVisitor.visitLocalVariable(), I see that previousDesc is Z. Not sure if that has anything to do with it.

The-Alchemist commented 9 years ago

Could you consider reopening this issue?

I think I reproduced it, and I submitted a pull request to reproduce it (https://github.com/jmockit/jmockit1/pull/175), along with instructions.

The-Alchemist commented 9 years ago

@rliesenfeld : Thanks so much! :)