{"action":"created","issue":{"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/895","labels_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/895/labels{/name}","comments_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/895/comments","events_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/895/events","html_url":"https://github.com/cucumber/cucumber-jvm/issues/895","id":99888316,"number":895,"title":"Defining several steps for the same function","user":{"login":"javierseixas","id":953900,"avatar_url":"https://avatars.githubusercontent.com/u/953900?v=3","gravatar_id":"","url":"https://api.github.com/users/javierseixas","html_url":"https://github.com/javierseixas","followers_url":"https://api.github.com/users/javierseixas/followers","following_url":"https://api.github.com/users/javierseixas/following{/other_user}","gists_url":"https://api.github.com/users/javierseixas/gists{/gist_id}","starred_url":"https://api.github.com/users/javierseixas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierseixas/subscriptions","organizations_url":"https://api.github.com/users/javierseixas/orgs","repos_url":"https://api.github.com/users/javierseixas/repos","events_url":"https://api.github.com/users/javierseixas/events{/privacy}","received_events_url":"https://api.github.com/users/javierseixas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-09T11:38:08Z","updated_at":"2015-08-09T11:59:53Z","closed_at":null,"body":"Is there any way to have more than one step definition (of the same type) for the same function? Something like:\r\n\r\n```java\r\n@Then(\"^it's do something$\")\r\n@Then(\"^it's do another thing$\")\r\npublic void this_is_my_function() throws Throwable {\r\n    // Do something\r\n}\r\n```\r\n\r\nI now that in Behat (PHP) and Specflow (C#) it is possible.\r\n\r\nI'm getting the following error:\r\n\r\n```\r\nError:(86, 5) java: cucumber.api.java.en.Then is not a repeatable annotation type\r\n```\r\n\r\nI found a [post](http://softwarecave.org/2014/05/20/repeating-annotations-in-java-8/) talking about a workaround for Java 7, and a solution for Java 8 using `@Repeatable`.\r\n\r\nI tried the Java 7 approach but it doesn't work either:\r\n\r\n```java\r\n@Thens({\r\n    @Then(\"^it's do something$\")\r\n    @Then(\"^it's do another thing$\")\r\n})\r\n```\r\n\r\nI guess I should define `@Thens` as a new annotation type, but I would like to depend only in what the library has.\r\n\r\nIs it possible to include the `@Repetable' annotation in the code?"},"comment":{"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/comments/129171067","html_url":"https://github.com/cucumber/cucumber-jvm/issues/895#issuecomment-129171067","issue_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/895","id":129171067,"user":{"login":"javierseixas","id":953900,"avatar_url":"https://avatars.githubusercontent.com/u/953900?v=3","gravatar_id":"","url":"https://api.github.com/users/javierseixas","html_url":"https://github.com/javierseixas","followers_url":"https://api.github.com/users/javierseixas/followers","following_url":"https://api.github.com/users/javierseixas/following{/other_user}","gists_url":"https://api.github.com/users/javierseixas/gists{/gist_id}","starred_url":"https://api.github.com/users/javierseixas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierseixas/subscriptions","organizations_url":"https://api.github.com/users/javierseixas/orgs","repos_url":"https://api.github.com/users/javierseixas/repos","events_url":"https://api.github.com/users/javierseixas/events{/privacy}","received_events_url":"https://api.github.com/users/javierseixas/received_events","type":"User","site_admin":false},"created_at":"2015-08-09T11:59:53Z","updated_at":"2015-08-09T11:59:53Z","body":"My real world example where I realised that was this:\r\n\r\n```\r\n@When(\"^it's ([a-z]+) is decreased to (\\\\d+)$\")\r\n@When(\"^it's ([a-z]+) is increased to (\\\\d+)$\")\r\npublic void it_s_feeling_is_increased_to(String feeling, int value) throws Throwable {\r\n    try {\r\n        Method method = tamagotchi.getClass().getMethod(feeling);\r\n        try {\r\n            assertThat(method.invoke(tamagotchi), is(value));\r\n        } catch (Exception e) {\r\n            // ...\r\n        }\r\n    } catch (Exception e) {\r\n        // ...\r\n    }\r\n}\r\n```\r\n\r\nIt's a Tamagotchi game. The first parameter is a feeling (hungriness, fullness...) and the second one is a value. By introspection I call the corresponding method to get the value for this feeling. The behaviour is the same in both cases, just calling an accessor and compare to a value.\r\n\r\nIn my case I don't think it makes domain language less precise, I think is just reusability of the step functions."}}