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

Proposed solution for #5457 gherkin scenarios not loaded from group file #5458

Merged
merged 4 commits into from Apr 5, 2019
Merged

Proposed solution for #5457 gherkin scenarios not loaded from group file #5458

merged 4 commits into from Apr 5, 2019

Conversation

mozillalives
Copy link
Contributor

A possible solution for the issue described in #5457. I have a couple of open questions though.

  • I am not familiar with the Codeception framework. Is Codeception\Lib\GroupManager the best place to address this issue or is there a better place?
  • I would like to write some tests to verify this issue. Can someone point me to a similar test to help me get started?
  • My use of strcasecmp looks like it will fail for multibyte strings. Are there suggestions on better alternatives? One I saw (that I linked to in a comment in the code) suggests using mb_strtolower instead.

Any help, tips or advice would be appreciated. Thanks.

@mozillalives
Copy link
Contributor Author

okey-dokey - looking at the output I can see at least a couple of tests that are failing because of my change. I'll address those and push up a commit.

@@ -118,6 +118,12 @@ public function groupsForTest(\PHPUnit\Framework\Test $test)
if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) {
$groups[] = $group;
}
// TODO: consider mb_strtolower per https://stackoverflow.com/a/5473569
if (method_exists($test, 'getMetadata')
&& strcasecmp($filename . ':' . $test->getMetadata()->getFeature(), $testPattern) === 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be UFT-8 compliant as put in your TODO
strcasecmp($filename . ':' . $test->getMetadata()->getFeature(), $testPattern) === 0to be replaced by mb_strtolower($filename . ':' . $test->getMetadata()->getFeature()) === mb_strtolower($testPattern)

@@ -118,6 +118,12 @@ public function groupsForTest(\PHPUnit\Framework\Test $test)
if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) {
$groups[] = $group;
}
// TODO: consider mb_strtolower per https://stackoverflow.com/a/5473569
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a case where metadata() method does not exist ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some tests it did not so I added the check to make sure it was there before I called it

@@ -118,6 +118,12 @@ public function groupsForTest(\PHPUnit\Framework\Test $test)
if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) {
$groups[] = $group;
}
// TODO: consider mb_strtolower per https://stackoverflow.com/a/5473569
if (method_exists($test, 'getMetadata')
&& strcasecmp($filename . ':' . $test->getMetadata()->getFeature(), $testPattern) === 0
Copy link
Contributor

@edno edno Apr 1, 2019

Choose a reason for hiding this comment

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

Since current solution is focused on Gherkin feature, before using $test->getMetadata()->getFeature(), you should verify that the current $test object is a Gherkin Test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do that. Are there any other types of tests that might benefit from this comparison though?

@mozillalives
Copy link
Contributor Author

@edno I still have the bigger question of - what tests should I write to verify this? I'm thinking I need to verify GroupManager so I've been digging into that. I would definitely appreciate any help you could give though.

@mozillalives
Copy link
Contributor Author

mozillalives commented Apr 2, 2019

@edno actually, I think I figured it out. I've added two tests that fail before my changes to GroupManager but pass after my changes. Do you see any issues with them?

Please note that the Japanese text I have used is supposed to be (at least according to Google) a translation of Jeff returns a faulty microwave. My apologies if it is not.

@edno
Copy link
Contributor

edno commented Apr 2, 2019

I've not encountered this issue myself, but tests look good.
Until you don't break existing tests that should be 👍

@mozillalives
Copy link
Contributor Author

Awesome! If this is all good, can we get this merged? My team is waiting for this change to run our automated tests.

@edno
Copy link
Contributor

edno commented Apr 3, 2019

Not sure when PR will be merged.
There're few of them in waiting, but I think that @Naktibalda and @DavertMik are quite busy with the next major release.
In the meanwhile, you can use a workaround so your team will be using your codeception codebase instead of the official one by adapting your composer.json (not tested):

{
  "repositories" : [
    {
      "type": "vcs",
      "url": "https://github.com/mozillalives/Codeception/tree/fix-gherkin-scenario-run"
    }
  ],
  "require-dev": {
    "codeception/codecetion":"2.5"
  }
}

@DavertMik
Copy link
Member

Thank you! Looks good to me

@DavertMik DavertMik merged commit 119bac0 into Codeception:2.5 Apr 5, 2019
DavertMik pushed a commit that referenced this pull request Apr 23, 2019
* Proposed solution for #5457 gherkin scenarios not loaded from group file (#5458)

* proposed solution for #5457 gherkin scenarios not loaded from group file

* testing for getMetaData method before calling it in GroupManager

* reformatting if statement to appease nitpick

* adding tests for #5457

* Update LOCAL_FILE constant for new version of phpseclib (#5461)

* Using button formaction attr in proceedSubmitForm method (#5440)

* Using button formaction attr in proceedSubmitForm method (AcceptanceTesterActions::submitForm)

* Update InnerBrowser.php

* Avoid removing required fields in cookies. (#5470)
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.

None yet

4 participants