Skip to content
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

Cucumber Scala - Java reflection in ScalaDsl - random test errors #761

Closed
jkrawczyk opened this issue Aug 14, 2014 · 2 comments · Fixed by #768
Closed

Cucumber Scala - Java reflection in ScalaDsl - random test errors #761

jkrawczyk opened this issue Aug 14, 2014 · 2 comments · Fixed by #768

Comments

@jkrawczyk
Copy link

The code introduced in the commit b589ced seems to have a bug in functionParams method.
The comment from the commit:

The functionParams method has to filter out JVM bridge methods to ensure
the correct version of the apply() method (with type parameter
information) is captured. Function objects only have one defined method
named apply() so taking the head of the list should always be safe.

It turns out that there may be more methods defined, e.g. inner, helper methods or synthetic methods when accessing Step's variables. In that case taking head after filtering out bridge methods is not enough. Cucumber tests fail randomly because getDeclaredMethods returns Methods without sorting or any particular order.

A quick solution is to add getName to filter but maybe there is a better fix for that.

f.getClass.getDeclaredMethods.filter(m => "apply".equals(m.getName) && !m.isBridge).head.getGenericParameterTypes

@manuelbernhardt
Copy link
Contributor

+1 on this issue, it's rather an annoyance as it renders the Scala module unusable.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants