new Cucumber.Options annotation

3,650 views
Skip to first unread message

David Kowis

unread,
Mar 29, 2012, 9:36:54 AM3/29/12
to cu...@googlegroups.com
I'm working on setting up a Junit test to allow our team to more
easily run a single feature via a Junit test instead of running our
entire integration suite in maven.

There used to be a way to tie a single feature file to a single junit
test:

@Feature( value = "myFeature.feature")

I'm digging through the cucumber-jvm source and noticing that this is
no longer possible, we'd have to individually tag them.

The new @Cucumber.Options(features = "/path/to/features") doesn't let
me set a path to an individual feature file. I don't think the code is
built to take individual files, but expects paths. At least that's
what I'm pretty sure is going on.

Is there a way I've missed that one can run an individual feature
without doing tags?

Thanks,
David

aslak hellesoy

unread,
Mar 29, 2012, 10:04:38 AM3/29/12
to cu...@googlegroups.com
On Thu, Mar 29, 2012 at 2:36 PM, David Kowis <dko...@shlrm.org> wrote:
> I'm working on setting up a Junit test to allow our team to more
> easily run a single feature via a Junit test instead of running our
> entire integration suite in maven.
>
> There used to be a way to tie a single feature file to a single junit
> test:
>
> @Feature( value = "myFeature.feature")
>
>
>
> I'm digging through the cucumber-jvm source and noticing that this is
> no longer possible, we'd have to individually tag them.
>
> The new @Cucumber.Options(features = "/path/to/features") doesn't let
> me set a path to an individual feature file. I don't think the code is
> built to take individual files, but expects paths.

I don't understand what you mean by files versus paths. Do you mean
absolute paths and relative paths?

Anyway, you have to pass a relative path (relative from the
CLASSPATH). For example, in the picocontainer module's RunCukesTest:

@Cucumber.Options(features =
"cucumber/runtime/java/picocontainer/enums.feature")

Ok?

Aslak

> At least that's
> what I'm pretty sure is going on.
>
> Is there a way I've missed that one can run an individual feature
> without doing tags?
>

Yes.

@Cucumber.Options(features = "")

> Thanks,
> David
>
> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
>

David Kowis

unread,
Mar 29, 2012, 10:10:35 AM3/29/12
to cu...@googlegroups.com
On 03/29/2012 09:04 AM, aslak hellesoy wrote:
> On Thu, Mar 29, 2012 at 2:36 PM, David Kowis <dko...@shlrm.org> wrote:
>> I'm working on setting up a Junit test to allow our team to more
>> easily run a single feature via a Junit test instead of running our
>> entire integration suite in maven.
>>
>> There used to be a way to tie a single feature file to a single junit
>> test:
>>
>> @Feature( value = "myFeature.feature")
>>
>>
>>
>> I'm digging through the cucumber-jvm source and noticing that this is
>> no longer possible, we'd have to individually tag them.
>>
>> The new @Cucumber.Options(features = "/path/to/features") doesn't let
>> me set a path to an individual feature file. I don't think the code is
>> built to take individual files, but expects paths.
>
> I don't understand what you mean by files versus paths. Do you mean
> absolute paths and relative paths?
>
> Anyway, you have to pass a relative path (relative from the
> CLASSPATH). For example, in the picocontainer module's RunCukesTest:
>
> @Cucumber.Options(features =
> "cucumber/runtime/java/picocontainer/enums.feature")

Hmm, I thought I tried that. Maybe I didn't quite do it right.

That example would run a single feature file right, and not run any of
the others in the "cucumber/runtime/java/picocontainer/" directory?

Maybe it was too early and I made a stupid typo. I'll double check and
make sure that I'm doing it right.

Thanks,
David

aslak hellesoy

unread,
Mar 29, 2012, 10:19:34 AM3/29/12
to cu...@googlegroups.com

Correct.

> Maybe it was too early and I made a stupid typo. I'll double check and
> make sure that I'm doing it right.
>

Ok!

David Kowis

unread,
Mar 29, 2012, 10:24:48 AM3/29/12
to cu...@googlegroups.com
On 03/29/2012 09:19 AM, aslak hellesoy wrote:
>>> @Cucumber.Options(features =
>>> "cucumber/runtime/java/picocontainer/enums.feature")
>>
>> Hmm, I thought I tried that. Maybe I didn't quite do it right.
>>
>> That example would run a single feature file right, and not run any of
>> the others in the "cucumber/runtime/java/picocontainer/" directory?
> Correct.
>
>> Maybe it was too early and I made a stupid typo. I'll double check and
>> make sure that I'm doing it right.

Yep, to wrap this up, I'm stupid, it works just fine. Must have had a
stupid typo or something.

Thanks,
David

aslak hellesoy

unread,
Jun 5, 2012, 2:50:47 PM6/5/12
to cu...@googlegroups.com
On Tue, Jun 5, 2012 at 6:34 PM, OnlineITBuddy <ad...@onlineitbuddy.com> wrote:
> Hi Aslak Hellesøy,
>
>
>
> This is OnlineITBudy.com team member. I use cucumber to execute out tests in
> parallel using JUnit. I am able to execute tests in parallel using
> specifying feature file name in “@Cucumber.options” annotation and I provide
> relative path of the file. And we use output as a JSON format. In JSON file
> when I see uri to the feature file is given as absolute path. Is there any
> way we can get relative path there? As we are making use of this JSON files
> to generate report which supports only relative path to generate html files.
>
>
>
> This is how I use annotations:
>
> @RunWith(Cucumber.class)
>
> @Cucumber.Options(features = "newyork.feature",format = {"pretty",
> "html:target/cucumber","json:target/newyork.json" })
>
>
>
>
>
> JSON output.
>
> From newyork.json
>
>
>
> [{"id":"it-should-be-possible-to-search-for-places-at-the-norwegian-meteorological-institute,-http://www.yr.no","description":"","name":"It
> should be possible to search for places at the Norwegian Meteorological
> Institute,
> http://www.yr.no","keyword":"Feature","line":1,"elements":[{"id":"it-should-be-possible-to-search-for-places-at-the-norwegian-meteorological-institute,-http://www.yr.no;locate-new-york","description":"","name":"Locate
> New
> York","keyword":"Scenario","line":3,"steps":[{"result":{"duration":10996933287,"status":"passed"},"name":"I
> want to know the weather forecast for coming days","keyword":"Given
> ","line":5,"match":{"location":"SearchStepDefinitions.prepareHomePage()"}},{"result":{"duration":4290197276,"status":"passed"},"name":"I
> search for New York","keyword":"When
> ","line":6,"match":{"arguments":[{"val":"New
> York","offset":13}],"location":"SearchStepDefinitions.search(String)"}},{"result":{"duration":3608102119,"status":"passed"},"name":"I
> should be able to get a weather forecast for New York","keyword":"Then
> ","line":7,"match":{"arguments":[{"val":"New
> York","offset":47}],"location":"SearchStepDefinitions.assertTheSearchResult(String)"}}],"type":"scenario"}],"uri":"C:\\Documents
> and Settings\\******\\My Documents\\GitHub\\bdt\\newyork.feature"}]
>
>
>
> "uri":"C:\\Documents and Settings\\******\\My
> Documents\\GitHub\\bdt\\newyork.feature" (I need relative path here.)
>

Ticket created: https://github.com/cucumber/cucumber-jvm/issues/337

Please don't hijack unrelated threads. Start a new topic instead. See
http://www.urbandictionary.com/define.php?term=thread%20hijacking
Also, please don't address requests to me personally. This is a
project with many contributors.

Cheers,
Aslak

>
>
> Thank you,
>
> OnlineITBuddy
> -- There are two rules:
>
> 1) Please prefix the subject with [Ruby], [JVM] or [JS]. This allows people
> to filter messages.
> 2) Please use interleaved answers
> http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
>
> You received this message because you are subscribed to the Google Groups
> Cukes group. To post to this group, send email to cu...@googlegroups.com. To
> unsubscribe from this group, send email to
> cukes+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/cukes?hl=en

OnlineITBuddy

unread,
Jun 5, 2012, 3:01:36 PM6/5/12
to cu...@googlegroups.com
Thank you


On Thursday, March 29, 2012 7:06:54 PM UTC+5:30, David Kowis wrote:
On Thursday, March 29, 2012 7:06:54 PM UTC+5:30, David Kowis wrote:
On Thursday, March 29, 2012 7:06:54 PM UTC+5:30, David Kowis wrote:
On Thursday, March 29, 2012 7:06:54 PM UTC+5:30, David Kowis wrote:
On Thursday, March 29, 2012 7:06:54 PM UTC+5:30, David Kowis wrote:

Matthew

unread,
Jun 5, 2012, 4:50:09 PM6/5/12
to cu...@googlegroups.com


On Wednesday, 6 June 2012 05:34:39 UTC+12, OnlineITBuddy wrote:

Hi Aslak Hellesøy,

 

This is OnlineITBudy.com team member. I use cucumber to execute out tests in parallel using JUnit. I am able to execute tests in parallel using specifying feature file name in “@Cucumber.options” annotation and I provide relative path of the file. And we use output as a JSON format. In JSON file when I see uri to the feature file is given as absolute path. Is there any way we can get relative path there? As we are making use of this JSON files to generate report which supports only relative path to generate html files.

 

This is how I use annotations:

@RunWith(Cucumber.class)

@Cucumber.Options(features = "newyork.feature",format = {"pretty", "html:target/cucumber","json:target/newyork.json" })

 

Try
@Cucumber.Options(features = "classpath:newyork.feature",format = {"pretty""html:target/cucumber","json:target/newyork.json" }) 

That hopefully will give you the output you need

 

 

JSON output.

From newyork.json

 

[{"id":"it-should-be-possible-to-search-for-places-at-the-norwegian-meteorological-institute,-http://www.yr.no","description":"","name":"It should be possible to search for places at the Norwegian Meteorological Institute, http://www.yr.no","keyword":"Feature","line":1,"elements":[{"id":"it-should-be-possible-to-search-for-places-at-the-norwegian-meteorological-institute,-http://www.yr.no;locate-new-york","description":"","name":"Locate New York","keyword":"Scenario","line":3,"steps":[{"result":{"duration":10996933287,"status":"passed"},"name":"I want to know the weather forecast for coming days","keyword":"Given ","line":5,"match":{"location":"SearchStepDefinitions.prepareHomePage()"}},{"result":{"duration":4290197276,"status":"passed"},"name":"I search for New York","keyword":"When ","line":6,"match":{"arguments":[{"val":"New York","offset":13}],"location":"SearchStepDefinitions.search(String)"}},{"result":{"duration":3608102119,"status":"passed"},"name":"I should be able to get a weather forecast for New York","keyword":"Then ","line":7,"match":{"arguments":[{"val":"New York","offset":47}],"location":"SearchStepDefinitions.assertTheSearchResult(String)"}}],"type":"scenario"}],"uri":"C:\\Documents and Settings\\******\\My Documents\\GitHub\\bdt\\newyork.feature"}]

 

"uri":"C:\\Documents and Settings\\******\\My Documents\\GitHub\\bdt\\newyork.feature" (I need relative path here.)

 

Thank you,

OnlineITBuddy



On Thursday, March 29, 2012 7:06:54 PM UTC+5:30, David Kowis wrote:

biswajit panda

unread,
Jun 7, 2012, 3:22:57 AM6/7/12
to cu...@googlegroups.com
Can u please tell me what are the different "format"s supported in @Cucumber.Options(format = {"pretty""html:target/cucumber"}) statement?

Aslak Hellesøy

unread,
Jun 7, 2012, 3:57:49 AM6/7/12
to cu...@googlegroups.com




On 7 Jun 2012, at 08:23, biswajit panda <biswaj...@gmail.com> wrote:

Can u please tell me what are the different "format"s supported in @Cucumber.Options(format = {"pretty""html:target/cucumber"}) statement?


See https://github.com/cucumber/cucumber-jvm/issues/338

You'll have to poke around the source until that's fixed.

Aslak
-- There are two rules:

biswajit panda

unread,
Jun 8, 2012, 1:48:02 AM6/8/12
to cu...@googlegroups.com
Ok..
So I think I have to wait..
Aslak
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
Reply all
Reply to author
Forward
0 new messages