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

[Core] Add --wip option #1381

Closed
wants to merge 6 commits into from
Closed

[Core] Add --wip option #1381

wants to merge 6 commits into from

Conversation

Heziode
Copy link
Contributor

@Heziode Heziode commented Jun 2, 2018

Summary

This feature is the java implementation of --wip of Cucumber-Ruby. But, instead of not support --wip with --strict (in Ruby version), this version do it

How Has This Been Tested?

I have do tests in:

  • Result
  • RuntimeOptions
  • Runtime

Test in ExitStatus are not relevant here because it is tested in Runtime, isn't it ?

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.

@Heziode Heziode changed the title feat(core): Add --wip option Add --wip option Jun 2, 2018
@@ -24,7 +25,8 @@ public void receive(TestCaseFinished event) {
}
};

ExitStatus() {
ExitStatus(boolean wip) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Both wip and strict are derived from RuntimeOptions. It is okay to inject the whole runtime options here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is done

Add whole RuntimeOptions
private boolean hasAlwaysOkStatus() {
return is(Result.Type.PASSED) || is(Result.Type.SKIPPED);
public boolean isOkWip(boolean isStrict) {
return hasAlwaysOkStatus(true) || !isStrict && hasOkWhenNotStrictStatus();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this method is needed.

When using --wip the build should fail when there are any passing results (when result.isOk(true/false) return true).

Copy link
Contributor Author

@Heziode Heziode Jun 2, 2018

Choose a reason for hiding this comment

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

When using --wip the build should fail when there are any passing results (when result.isOk(true/false) return true).

Are you sure ?
Because if I do this, when it return false for undefined in strict mode I attempt to obtain result 1 but I get 0 (with my current code, that are not currently pushed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mpkorstanje If I only use isOk, and I do what you tell, I obtain an unexpected behaviour with strict mode.

With wip and strict, if I have an undefined step, the result is 0 instead of 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought it wasn't possible to use wip and strict in together. But if it is, that makes sense. An undefined result in strict mode makes the test fail. So when running with wip and strict it should pass. That is what I get from reading work_in_progress.feature:

  In order to ensure that feature scenarios do not pass until they are expected to
  Developers should be able to run cucumber in a mode that
            - will fail if any scenario passes completely
            - will not fail otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, do you want I disable the use of strict with wip ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you think the behaviour is unexpected?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mentioned somewhere else that I couldn’t remember why we disallowe strict and wip at the same time.

If we can’t think of a good reason for it (I can’t) we should allow it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am thinking the same thing. But I am trying to work out why Heziode thinks the result of combining wip and strict with an undefined result is unexpected.

Copy link
Contributor Author

@Heziode Heziode Jun 3, 2018

Choose a reason for hiding this comment

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

Here is a result I want to expect:

  • --wip: Test fail only if one or more scenario have status PASSED
  • --wip + --strict: Test fail if one or more scenario have status different than FAILED

What do you think about this ?

public byte exitStatus() {
return results.isEmpty() ||
(runtimeOptions.isWip() ? max(results, SEVERITY).isOkWip(runtimeOptions.isStrict()) :
max(results, SEVERITY).isOk(runtimeOptions.isStrict())) ? 0x0 : ERRORS;
Copy link
Contributor

@mpkorstanje mpkorstanje Jun 2, 2018

Choose a reason for hiding this comment

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

It's okay to use if statements here. You can use guard clauses to handle the empty case and the wip case.

I also think this will fail when there is one test case that passes and one test case that failed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test case to prove it works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I can add test to check this, but… where I write it ?

Copy link
Contributor

@mpkorstanje mpkorstanje Jun 2, 2018

Choose a reason for hiding this comment

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

In runtime test. But you have to test with moire then one event on the bus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is (normally) fixed with 99e535e

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Jun 3, 2018

Well I made a table. I used the work_in_progress.feature for the --wip, --no-strict column, the --no-wip columns are how cucumber currently works. The --wip --strict column is just the two obvious ones.

           |       --wip            |       --no-wip         |
           | --strict | --no-strict | --strict | --no-strict | 
PASSED     |   fail   |  fail       |   pass   |  pass       |
SKIPPED    |    ?     |  ?          |   pass   |  pass       |
PENDING    |    ?     |  pass       |   fail   |  pass       |
UNDEFINED  |    ?     |  pass       |   fail   |  pass       |
AMBIGUOUS  |    ?     |  pass       |   fail   |  fail       |
FAILED     |  pass    |  pass       |   fail   |  fail       |

The question mark at --wip --no-strict is okay because as far as I know you can't skip steps in ruby without making a prior step fail.

You can however skip steps in java using Assume. So we have two options to fill out that one question mark:

A:

           |       --wip            |       --no-wip         |
           | --strict | --no-strict | --strict | --no-strict | 
PASSED     |   fail   |  fail       |   pass   |  pass       |
SKIPPED    |    ?     |  fail       |   pass   |  pass       |
PENDING    |    ?     |  pass       |   fail   |  pass       |
UNDEFINED  |    ?     |  pass       |   fail   |  pass       |
AMBIGUOUS  |    ?     |  pass       |   fail   |  fail       |
FAILED     |  pass    |  pass       |   fail   |  fail       |

Interesting here is that --wip --no-strict is the inverse of --no-wip --strict. Which would explain why wip and strict modes can't be used together. The wip mode is already strict (and inversed).

B:

           |       --wip            |       --no-wip         |
           | --strict | --no-strict | --strict | --no-strict | 
PASSED     |   fail   |  fail       |   pass   |  pass       |
SKIPPED    |    ?     |  pass       |   pass   |  pass       |
PENDING    |    ?     |  pass       |   fail   |  pass       |
UNDEFINED  |    ?     |  pass       |   fail   |  pass       |
AMBIGUOUS  |    ?     |  pass       |   fail   |  fail       |
FAILED     |  pass    |  pass       |   fail   |  fail       |

You can also make an argument for this. When work is in progress you wouldn't expect a the build to fail because you made a scenario pass by skipping it entirely.

And again the wip mode more stricter then strict (and inverted).

--wip + --strict: Test fail if one or more scenario have status different than FAILED

That would also be a logical alternative.

B2:

           |       --wip            |       --no-wip         |
           | --strict | --no-strict | --strict | --no-strict | 
PASSED     |   fail   |  fail       |   pass   |  pass       |
SKIPPED    |   fail   |  pass       |   pass   |  pass       |
PENDING    |   fail   |  pass       |   fail   |  pass       |
UNDEFINED  |   fail   |  pass       |   fail   |  pass       |
AMBIGUOUS  |   fail   |  pass       |   fail   |  fail       |
FAILED     |   pass   |  pass       |   fail   |  fail       |

@Heziode What use case did you have in mind here?

@aslakhellesoy what kind of work flow was wip supposed to support anyway?

@Heziode
Copy link
Contributor Author

Heziode commented Jun 4, 2018

@mpkorstanje The option B2 is what I expect. But, in what use case use --strict with --wip, I do not know ...

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Jun 4, 2018

Let's go for option B2 then. Basically just ignore strict when wip is active.

           |       --wip            |       --no-wip         |
           | --strict | --no-strict | --strict | --no-strict | 
PASSED     |   fail   |  fail       |   pass   |  pass       |
SKIPPED    |   pass   |  pass       |   pass   |  pass       |
PENDING    |   pass   |  pass       |   fail   |  pass       |
UNDEFINED  |   pass   |  pass       |   fail   |  pass       |
AMBIGUOUS  |   pass   |  pass       |   fail   |  fail       |
FAILED     |   pass   |  pass       |   fail   |  fail       |

A very concise way to check if the least severe result is a passed would be: min(results, SEVERITY).is(Type.PASSED); so the wip methods in Result aren't needed.

Spec:
           |       --wip            |       --no-wip         |
           | --strict | --no-strict | --strict | --no-strict |
PASSED     |   fail   |  fail       |   pass   |  pass       |
SKIPPED    |   pass   |  pass       |   pass   |  pass       |
PENDING    |   pass   |  pass       |   fail   |  pass       |
UNDEFINED  |   pass   |  pass       |   fail   |  pass       |
AMBIGUOUS  |   pass   |  pass       |   fail   |  fail       |
FAILED     |   pass   |  pass       |   fail   |  fail       |
@Heziode
Copy link
Contributor Author

Heziode commented Jun 4, 2018

It is done.

@mpkorstanje
Copy link
Contributor

Looks good. I'll try to merge this and the runtime constructors branch later this week.

@mpkorstanje mpkorstanje changed the title Add --wip option [Core] Add --wip option Jun 5, 2018
@mpkorstanje
Copy link
Contributor

Alright. I had some spare time. It has been merged.

Thanks for contributing!

@Heziode Heziode deleted the feature/wip-option branch June 5, 2018 17:41
@lock
Copy link

lock bot commented Jun 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants