{"action":"created","issue":{"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/835","labels_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/835/labels{/name}","comments_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/835/comments","events_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/835/events","html_url":"https://github.com/cucumber/cucumber-jvm/issues/835","id":57499997,"number":835,"title":"Cucumber Spring is not finding my step definitions","user":{"login":"JasonSmiley","id":3218562,"avatar_url":"https://avatars.githubusercontent.com/u/3218562?v=3","gravatar_id":"","url":"https://api.github.com/users/JasonSmiley","html_url":"https://github.com/JasonSmiley","followers_url":"https://api.github.com/users/JasonSmiley/followers","following_url":"https://api.github.com/users/JasonSmiley/following{/other_user}","gists_url":"https://api.github.com/users/JasonSmiley/gists{/gist_id}","starred_url":"https://api.github.com/users/JasonSmiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasonSmiley/subscriptions","organizations_url":"https://api.github.com/users/JasonSmiley/orgs","repos_url":"https://api.github.com/users/JasonSmiley/repos","events_url":"https://api.github.com/users/JasonSmiley/events{/privacy}","received_events_url":"https://api.github.com/users/JasonSmiley/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-12T18:32:17Z","updated_at":"2015-02-15T20:44:30Z","closed_at":"2015-02-12T18:48:23Z","body":"Since there is no great documentation on how to use this, I will admit I am possibly setting up my environment incorrectly. However, I can launch the WebApp (I see building of resources in console), I can see cucumber finding my features to execute, but when it tries to actually execute them, it says my steps are not defined and test is ignored.\r\n\r\nMy code can be found in this stack over flow question http://stackoverflow.com/questions/28466479/cucumber-spring-is-not-finding-step-definitions\r\n\r\nTo be honest, it looks like a bug in the cucumber to me at the moment, but since there is no good documentation on this, I can't tell if I am doing something wrong. Please advise!\r\n\r\ncurrently using 1.2.2 Cucumber API\r\n"},"comment":{"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/comments/74435920","html_url":"https://github.com/cucumber/cucumber-jvm/issues/835#issuecomment-74435920","issue_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/835","id":74435920,"user":{"login":"brasmusson","id":2105308,"avatar_url":"https://avatars.githubusercontent.com/u/2105308?v=3","gravatar_id":"","url":"https://api.github.com/users/brasmusson","html_url":"https://github.com/brasmusson","followers_url":"https://api.github.com/users/brasmusson/followers","following_url":"https://api.github.com/users/brasmusson/following{/other_user}","gists_url":"https://api.github.com/users/brasmusson/gists{/gist_id}","starred_url":"https://api.github.com/users/brasmusson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brasmusson/subscriptions","organizations_url":"https://api.github.com/users/brasmusson/orgs","repos_url":"https://api.github.com/users/brasmusson/repos","events_url":"https://api.github.com/users/brasmusson/events{/privacy}","received_events_url":"https://api.github.com/users/brasmusson/received_events","type":"User","site_admin":false},"created_at":"2015-02-15T20:44:30Z","updated_at":"2015-02-15T20:44:30Z","body":"@JasonSmiley I copied the code from your question at stackoverflow and I basically find no problem with it with respect to \"finding Step Definitions\". I put it in a [GitHub project](https://github.com/brasmusson/spring-skeleton), you can try it yourself if you want (the GitHub project also include the [Cucumber-Java-Skeleton project](https://github.com/cucumber/cucumber-java-skeleton) changed to use cucumber-spring).\r\n\r\nSome notes though:\r\n * The question \"Cucumber-spring is not finding Step Definitions\" is missleading, it is always cucumber-core that search for Step Definition, then cucumber-core passes the found Step Definition classes to the backend (and with cucumber-spring on the classpath, that would be cucumber-spring) with the intention \"when I ask for a instance of any of this classes, create it for me please\".\r\n *  Currently the glue parameter on the runner class (on StackOverflow page) is specified as `glue = \"stepDefinitions.ItemServiceControllerTestsSteps\"`, the glue parameter should specify base-package(s) for the search for Step Definition so it should be specified `glue = \"stepDefinitions\"` (I'm pretty sure it was that the first time I looked at the StackOverflow page).\r\n * I notice that the JUnit class has a `@WebAppConfiguration` annotation together with the `@ContextConfiguration` annotation, but the Step Definition class only has a `@ContextConfiguration` annotation. It has nothing to do with finding Step Definitions, but I you want to use whatever features the `@WebAppConfiguration` enables when running your features, you need to put it together with the `@ContextConfiguration` (or `@ContextHierarchy`) annotation on the Step Definition class with the `@ContextConfiguration` (or `@ContextHierarchy`) annotation.\r\n * Step Definition classes need a default constructor for the Spring Context to be able to instantiate them (as far as I can tell, I had to add one to the ItemServiceControllerTestsSteps to make it work)\r\n * Returning values from Step Definitions does not seem to ruin anything, but it is not useful since the value returned will not be used.\r\n * It seems that Step Definitions can be declared static, but the whole idea with Cucumber-JVM is that the Step Definition classes are created fresh for each Scenario.\r\n * To answer a questing on a comment you added and deleted here in this discussion. Yes, cucumber-spring can be used to connect different Step Definition class instances with `@Autowire`, see the example [here](https://github.com/brasmusson/spring-skeleton/blob/master/src/test/java/skeleton/Stepdefs2.java#L12-L21) were one Step Definition access a field on another Step Definition. Note that the Step Definition classes should not be declared a beans explicitly, cucumber-spring will add bean definition to the Spring Context itself, making sure that they get the scope `cucumber-glue` so they will be created fresh for each Scenario."}}