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

Unify Native and Core behaviour #131

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

ilyapuchka
Copy link
Collaborator

Resolves #124

There are currently several differences in behaviour of "Native" and "Core" scenarios:

  • native scenarios are executed in order. This may encourage to make scenarios dependent on each other, which is widely considered as a bad practice
  • in case of duplicated steps native scenarios raise exception while core scenarios just pick the first step declaration. We can chose to not allow them in core too but anyway behaviour should be the same as in native.
  • each example in native tests results in separate "runtime" XCTestCase. This makes it harder to guess the name of the test to run it separately via xcodebuild test with -only-testing parameter.

It would be better if "native" and "core" behave similarly, especially if we are moving in the direction of generating "core" tests from "native" tests.

@deanWombourne
Copy link
Contributor

This looks great, apart from the fact it directly contradicts #35 :( @smaljaar Can you remember why you had a requirement for the sorting of native tests?

@ilyapuchka
Copy link
Collaborator Author

@deanWombourne yes it does contradict that change but I think it encourages a bad practice (we actually do have such tests which rely on the order of execution and fail when run separately). Also I think cucumber itself does not guarantee tests order and that's made on purpose.

@deanWombourne
Copy link
Contributor

@ilyapuchka I agree - tests shouldn't really on each other. However, I'm loath to change this without at least knowing why we were asked to implement it.

Also, looking at cucumber, it's default behaviour is what we have implemented at the moment (i.e. scenarios are run in the order they are found in the feature file) and while I agree or disagree with that, one of the guides I use when deciding what to do is 'what does cucumber do'!

@smaljaar
Copy link
Contributor

smaljaar commented Oct 2, 2018

This looks great, apart from the fact it directly contradicts #35 :( @smaljaar Can you remember why you had a requirement for the sorting of native tests?

Yes, if I remember correctly at the time I was working on a project with feature parity between iOS and Android. On Android we were using Cucumber and I noticed the order of execution was different between platforms (for some reason iOS was sorting them backwards, but that got fixed in PR #35).

I agree with @ilyapuchka that we should avoid (aiding in) transferring state between tests, but on the other hand it is also just natural and cucumber like to run the examples/scenarios as they are specified. Even if you remove sorting XCTest will still execute the tests in alphabetical order, I think, unless you explicitly add scrambling logic to avoid that.

Actually, there is a new feature to randomise the execution order of tests in Xcode, maybe you could use that feature to remove the ordering instead of removing it from the XCTest-Gherkin lib all together @ilyapuchka ?

@ilyapuchka ilyapuchka mentioned this pull request Oct 2, 2018
@ilyapuchka
Copy link
Collaborator Author

ilyapuchka commented Nov 26, 2018

Actually, there is a new feature to randomise the execution order of tests in Xcode, maybe you could use that feature to remove the ordering instead of removing it from the XCTest-Gherkin lib all together

I'm not sure that will work with tests created at runtime (from native feature files).
Another issue is that it is currently using indexes in runtime test names which makes it harder to invoke particular scenario from command line using testing-only option as you need to guess the order of the scenario in the feature file to get its name correctly.
In the end it leads to inconsistencies in behaviour between two kinds of test that may be puzzling when users are migrating from one type of tests to another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants