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

Add ambiguous result type #139

Closed

Conversation

MadameSheema
Copy link
Member

@MadameSheema MadameSheema commented Jul 9, 2017

Summary

Added a new result type for tests that encounter ambiguous steps.

Details

With this PR and the PR: cucumber/cucumber-ruby#1132 we are trying to fix the issue #1113

Motivation and Context

cucumber/cucumber-ruby#1113

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I've added tests for my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Added a new result type for tests that encounter ambiguous steps.
@MadameSheema
Copy link
Member Author

@mattwynne @tooky please take a look at this and the new changes in the old PR in order to know if we are going to the right direction or not. Thx :)

@MadameSheema MadameSheema reopened this Jul 9, 2017
@mattwynne
Copy link
Member

mattwynne commented Jul 9, 2017

Hi @MadameSheema you're definitely going in the right direction! Using this Raisable type should automatically count the step as failed if you raise it as the step is executed.

I think there's a subtle question about whether this specialisation of the Result::Raisable needs to live in the core, or whether it could just live in the "front-end" cucumber gem. However I think let's leave that question for now and we can look at refactoring once you have something working.

@enkessler
Copy link
Contributor

@mattwynne So far, we've been putting the new stuff next to its relatives. So if these new classes don't belong here, then there's a good chance that the existing ones don't belong here either.

We've got one of the tests to the point where it just fails instead of exploding, but we haven't yet found the spot in the code that is responsible for outputting the ambiguous step message. The message that is in the error class class looks exactly like what we want but we need to get it output somewhere.

@brasmusson
Copy link
Contributor

Using this Raisable type should automatically count the step as failed if you raise it as the step is executed.

@mattwynne Really? Undefined, Skipped, and Pending are Raisable, but not Failed. Isn't it the other way around, when a Raisable is raised in the step definition the result becomes the type raised? But this is what we want here, that the result becomes Ambiguous?

end

def to_s
"F"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should rather be "A" - for "Ambiguous".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I hit this in Cucumber JS the other day, and I wonder if we should just do exactly the same as them to stay consistent (except offering to --guess).

💡 in fact, why don't we just steal their acceptance test...

https://github.com/cucumber/cucumber-js/blob/master/features/ambiguous_step.feature

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theft? In Open Source? For shame! ;)

Seriously though, yes, that was an initial idea but it somehow ended up starting with the even more basic case of failure rather than a special return type like ambiguous. Given what i have now seen of the code, however, I may be able to make it return the correct type, even if I still can't get the output correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's steal the idea :P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starting with the even more basic case of failure

In that case, an Ambiguous class should not be defined here, so defining it here implies a new result category in the summary (N Scenarios (X failed, Y ambiguous, ... )

end

def ok?(be_strict = false)
!be_strict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be false so that the exit code becomes non-zero when an ambiguous step is found?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's based on what the Undefined type is does. It's not good but it's not bad unless --strict is used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the feature file says Then it should fail with:, and if it is not bad unless --strict then the scenario should say Then it should pass with:

@brasmusson
Copy link
Contributor

The other result types have specs in result_spec.rb, so it should be updated to cover also the Ambiguous result type.

@mattwynne
Copy link
Member

mattwynne commented Jul 11, 2017

@mattwynne Really? Undefined, Skipped, and Pending are Raisable, but not Failed. Isn't it the other way around, when a Raisable is raised in the step definition the result becomes the type raised? But this is what we want here, that the result becomes Ambiguous?

You're right, as usual. 😀 Sorry for adding any confusion.

Copy link
Contributor

@brasmusson brasmusson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs to be rebased since #140 has made some ground work for adding new result types.

end

def ok?(be_strict = false)
!be_strict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the feature file says Then it should fail with:, and if it is not bad unless --strict then the scenario should say Then it should pass with:

end

def to_s
"F"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starting with the even more basic case of failure

In that case, an Ambiguous class should not be defined here, so defining it here implies a new result category in the summary (N Scenarios (X failed, Y ambiguous, ... )

@@ -16,7 +16,7 @@ def self.query_methods(result_type)
result_type
end

[:passed, :failed, :undefined, :unknown, :skipped, :pending].each do |possible_result_type|
[:passed, :failed, :undefined, :unknown, :skipped, :pending, :ambiguous].each do |possible_result_type|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These symbols definitions has been moved to a module level constant, so :ambiguous should be added there instead, and since the order control the order in the summary listing, I think is should be defined directly after :failed

include Result.query_methods :ambiguous

def describe_to(visitor, *args)
visitor.failed(*args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ambiguous result should describe itself as ambiguous to the visitors (which also requires and ambiguous method in the RunningTestCase - same definition as undefined works)

"F"
end

def ok?(be_strict = false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the ok? methods are defined as class methods - and for Ambiguous is should always be false (as long as the scenarios says Then it should fail with)

@stale
Copy link

stale bot commented Nov 8, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Nov 8, 2017
@brasmusson brasmusson added the 🧷 pinned Tells Stalebot not to close this issue label Nov 10, 2017
@stale stale bot removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Nov 10, 2017
@mattwynne mattwynne closed this May 1, 2021
@mattwynne mattwynne deleted the branch cucumber:master May 1, 2021 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧷 pinned Tells Stalebot not to close this issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants