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

Story editor does not resolve steps from referenced projects or jars on classpath #5

Closed
pmiklos opened this issue Nov 8, 2012 · 3 comments · Fixed by #9
Closed

Comments

@pmiklos
Copy link

pmiklos commented Nov 8, 2012

Hi,

JBehave Story Editor does not resolve any steps declared in a separate library available on the classpath. I have a maven project with stories which depends a library containing the steps. It runs fine, but unfortunately the story editor reports a warning for each Given, And and Then statements like this:

"No step is matching <attribute N0_I0012 evaluates to <maturitydate>>"

The code completion does not work either.

The steps project is resolved by the maven eclipse plugin and is on the classpath. I have tried to manually add the steps project as referenced project, but that also did not help. Also tried to explicitly include my steps package and classes in the Class Scanner preferences , no luck.

Note, that I extracted the library from the story project and before that, when stories and steps were in the same project, it worked fine.

I am using JBehave Eclipse 1.0.0.20120727-0957
Eclipse: Version: 3.7.1 Build id: M20110909-1335

Thanks,
Peter

@pmiklos
Copy link
Author

pmiklos commented Nov 8, 2012

I cloned the repository to test the latest version. I debugged it a little bit to see what StepLocator and HierarchicalContainer do, and noticed that in case of maven jar dependencies, the child containers it traverses through are FlatContainer instances without any further child elements. I expected if it finds a jar it would walk through on its containing class to look for candidate steps.

@pmiklos
Copy link
Author

pmiklos commented Nov 8, 2012

further debugging, it looks like, when it scans Java classes, the following exception happens (not printed to any output):

java.lang.IllegalArgumentException: No enum const class org.jbehave.core.steps.StepType.ORG.JBEHAVE.CORE.ANNOTATIONS.GIVEN

Unfortunately I could not get the stacktrace, but it is thrown in JBehaveProject.addStepCandidates at this point:

stepType = StepType.valueOf(elementName.toUpperCase());

So, the elementName seems to be the fully qualified name of the @Given annotation and it cannot be resolved to the StepType.GIVEN using the valueOf method.

@pmiklos
Copy link
Author

pmiklos commented Nov 8, 2012

According to the javadoc of org.eclipse.jdt.core.IAnnotation.getElementName() this behavior is expected:

Returns the name of this annotation. If this annotation is coming from a compilation unit, this is either a simple name (e.g. for @MyAnnot, the name is "MyAnnot"), or a qualified name (e.g. for @x. y. MyAnnot, the name is "x.y.MyAnnot"). If this annotation is coming from a class file, this is always a fully qualified name.

The candidate steps in a maven dependency are class files rather than compilation units. So fully qualified names will be returned and so it will not match the StepType enums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant