For issue #186. Cucumber tries to instantiate parent classes via Spring #193

merged 1 commit into from Feb 6, 2012

2 participants


As requested I've created failing test:

To fix the bug, I've passed additions parameter "Class<?> candidateClass" to JavaBackend.addHook and JavaBackend.addStepDefinition methods. Fixed affected test cases.

While running build I've noticed that cucumber-spring test cases broke. That was because some inner class with hooks was discovered. Not sure if those should be ignored or instantiated by creating parent class first. To be safe I've just "replaced" such classes with their super classes. That is what happening in current implementation.
See following ClasspathMethodScanner chunk of code for details:

            while (candidateClass.getEnclosingClass() != null && !Modifier.isStatic(candidateClass.getModifiers())
                    && candidateClass != Object.class) {
                // those can't be instantiated without container class present.
                candidateClass = candidateClass.getSuperclass();
@vasiliygagin vasiliygagin Issue #186. Making sure that Stepdef class is registered with ObjectF…
…actory not a superclass when superclass declares anotated methods
@aslakhellesoy aslakhellesoy merged commit fdc60bc into cucumber:master Feb 6, 2012

This is a replacement for pull request #188. Commits in this request have no history of bad copyright comments

Cucumber member

Thanks @vasiliygagin I have already merged it.

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