kevinrood / teamcity_formatter

TeamCity cucumber output formatter
Apache License 2.0
5 stars 8 forks source link

Tagged Scenario Examples Crashes #7

Closed jonfinerty closed 7 years ago

jonfinerty commented 7 years ago

Hi,

I'm using a Scenario Outline with multiple examples tables, for different tags and when the formatter tries to process this I get the following crash:

undefined method `column_values' for nil:NilClass (NoMethodError)
teamcity_formatter-0.8.2/lib/team_city_formatter/formatter.rb:62:in `before_table_row'
cucumber-2.3.3/lib/cucumber/formatter/ignore_missing_messages.rb:10:in `method_missing'
cucumber-2.3.3/lib/cucumber/formatter/legacy_api/adapter.rb:825:in `before'
...

Here's an example of the kind of thing I'm doing with the Scenario Outlines:

Scenario Outline: Testing a certain feature
    Given I test the value: <test_value> and <second_value>
    Then I should have a positive outcome

  @smoke
    Examples:
      | test_value | second_value | 
      | A          | B            | 

  @regression
    Examples:
      | test_value  | second_value | 
      | C           | D            | 
      | E           | F            | 
kevinrood commented 7 years ago

@jonfinerty I am sorry to hear you experienced an issue using teamcity_formatter and thank you for reporting it.

I was not aware you could tag an Examples block, that's neat!

That said, to resolve this problem, I would need to have a full example of a failing case. I literally have to break into a debugging session to see how cucumber is modeling this situation in it's code. It is generally not clear from looking at the cucumber gem's source (at least for me).

Is a trivial breaking example something you might be able to put together in a gist (a full on tiny test suite example)?

In the interim, I think you could duplicate the test and tag the scenario outline itself:

@smoke
Scenario Outline: Testing a certain feature
...

@regression
Scenario Outline: Testing a certain feature
...

Your thoughts?

jonfinerty commented 7 years ago

Thanks for the quick response, Sure I can get you that gist.

I think I've found the issue, in https://github.com/kevinrood/teamcity_formatter/blob/master/lib/team_city_formatter/formatter.rb#L106 theres the following line

cuke_example_rows = cuke_scenario_outline.examples_tables.first.example_rows

That first seems to be the culprit, as it just takes the first example table, when there could (although rarely :) ) be multiple tables. I've got the formatter hack-erly working by replacing that with:

cuke_example_rows = cuke_scenario_outline.examples_tables.map {|table| table.example_rows}.flatten

There certainly a more elegant way of fixing this, but hopefully this points you in the right direction.

kevinrood commented 7 years ago

@jonfinerty The only thing I can think of which would be more elegant is this (pretty close to what you have already :smile:):

cuke_example_rows = cuke_scenario_outline.examples_tables.map(&:example_rows).flatten

Would you like to open a pull request? My main concern would be to not break other non-multi examples block cases. It may take me some time before I could get this change tested using a customer's test suite that is fairly comprehensive.

kevinrood commented 7 years ago

@jonfinerty and I see you did open a a pull request :smile:

jonfinerty commented 7 years ago

😄 yup, but your ruby is better than mine. No problem about the wait, certainly wouldn't want to break the normal examples

jonfinerty commented 7 years ago

Hi, sorry to nag. Have you had a chance to run this on a large test suite? We've run it internally, but we don't have the most comprehensive cucumber suites.

jonfinerty commented 7 years ago

@kevinrood I see you've merged the fix, thanks! Could you push a new gem version so we can start using it and I can close this issue?

kevinrood commented 7 years ago

Done, thanks!