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

(Feature Request) Support running scenario by line number #4522

Closed
gd46 opened this issue Oct 3, 2017 · 14 comments
Closed

(Feature Request) Support running scenario by line number #4522

gd46 opened this issue Oct 3, 2017 · 14 comments

Comments

@gd46
Copy link

gd46 commented Oct 3, 2017

I'd like to see support to be able to pass protractor a location, ie: a file name:line number and have it run that specific test.

Cucumber-js has a way of doing this, and I know its not part of the core support of protractor, but I think it would be useful for other test frameworks as well if possible. If you could do this then you can run each scenario in parallel.

Take this example:

https://github.com/gd46/dibellag-automation-framework/blob/master/configuration.js#L32

I am using getMultipleCapabilities function to run each file in parallel by creating my own custom shards based on cucumber features that meet the tag expression. Cucumber-js allows tests to be run by line number, and in the current code I have setup I am able to extract that but not run them how cucumber expects.

For example:

Given the follow spec options:

--specs test/features/example.feature:8

I would expect it to run just the one scenario on line 8.

@wswebcreation
Copy link
Contributor

Hi @gd46

Tnx for your feature request. Are you talking here only about CucumberJS? If so, wouldn't that be the responsibility of the framework like protractor-cucumber-framework or your own to support that?

If we look at Jasmine and Mocha I think it would be a different story because you works the describe and before- / after methods that are initially only loaded when you run the complete file.

@vikerman / @cnishina ,
What do you think about this feature request. Is this feasible?

@gd46
Copy link
Author

gd46 commented Oct 4, 2017

@wswebcreation Thank you for the quick reply! Yes I was talking about CucumberJS. I wasnt sure if this was a protractor issue or something that protractor-cucumber-framework could handle. At the moment im using cucumber so that was my main interest, and I saw cucumber-js supported it but like I said if you pass the fileName:line number to protractor it didnt recognize that I wanted to run that scenario. If this issue is misplaced and I should log it with protractor-cucumber-framework please let me know and we can close and ill open an issue there.. But I do think this would be a great feature and allow for even better parallel testing.

@gd46 gd46 closed this as completed Oct 4, 2017
@gd46
Copy link
Author

gd46 commented Oct 4, 2017

Sorry was on my phone didn't mean to hit the comment and close

@gd46 gd46 reopened this Oct 4, 2017
@wswebcreation
Copy link
Contributor

Hi @gd46

I'm wondering what the issue / feature request would hold. I just created a simple test and it works as you describe / want.

# Featurefile
Feature: Run a test by line number

    Scenario: Skip scenario on line 3
        Given I skip
        Then I'm skipped

    Scenario: Skip scenario on line 7
        Given I skip
        Then I feel like a skipyball

    Scenario: Run the scenario on line 11
        Given I foo a bar
        Then I have a foo-bar
node node_modules/.bin/protractor e2e-tests/config/protractor.e2e.local.conf.js --specs e2e-tests/features/example.feature:11
[06:27:45] I/launcher - Running 1 instances of WebDriver
[06:27:45] I/local - Starting selenium standalone server...
[06:27:45] I/local - Selenium standalone server started at http://10.236.54.137:62276/wd/hub
Feature: Run a test by line number

  Scenario: Run the scenario on line 11
  ✔ Given I foo a bar
  ✔ Then I have a foo-bar

1 scenario (1 passed)
2 steps (2 passed)
0m04.132s
[06:27:52] I/local - Shutting down selenium standalone server.
[06:27:52] I/launcher - 0 instance(s) of WebDriver still running
[06:27:52] I/launcher - chrome #01 passed

@gd46
Copy link
Author

gd46 commented Oct 5, 2017

hmm thats odd I tried it again and I do see that working. Im not sure if I had a typo or something but it does seem to work. Im going to try again with what I wanted to do to try to run scenarios in parallel using this.

@gd46
Copy link
Author

gd46 commented Oct 5, 2017

Im still trying this out, but at the moment I see it still pick up both scenarios within a file.

Given this result:

{
    "pickle": {
      "tags": [
        {
          "name": "@example3",
          "location": {
            "line": 7,
            "column": 3
          }
        }
      ],
      "name": "Should return parameter as int",
      "language": "en",
      "locations": [
        {
          "line": 8,
          "column": 3
        }
      ],
      "steps": [
        {
          "text": "I have 42 cucumbers",
          "arguments": [
            
          ],
          "locations": [
            {
              "line": 9,
              "column": 10
            }
          ]
        }
      ]
    },
    "uri": "test\/features\/examples\/example.feature"
  }

Would you use the locations line under name?

This is my example feature:

Feature: example

  @example
  Scenario: Custom Transform should take belly and capitalize it
  	Given I have cucumbers in my belly

  @example3
  Scenario: Should return parameter as int
  	Given I have 42 cucumbers

And if I run:

test/features/example/example.feature:8

I see it run both scenarios

@wswebcreation
Copy link
Contributor

Can you then please provide a working example where you see this issue so I can debug it

@gd46
Copy link
Author

gd46 commented Oct 5, 2017

You beat me to it! Thank you for such quick replies.

If you checkout this branch:

https://github.com/gd46/dibellag-automation-framework/tree/parallel_scenarios

And run the following Im expecting to run each of the three scenarios in parallel(going to clean it up more once It works properly)

npm test -- -p --browserName chrome --maxSessions 3

@wswebcreation
Copy link
Contributor

Tnx, will check it out later. Hope to have time for it this evening

@gd46
Copy link
Author

gd46 commented Oct 5, 2017

Thank you so much that would be great! Just to clarify the current issue once more. From what I can tell now it seems to ignore the file number on the end and run each of the specified feature files.

@gd46
Copy link
Author

gd46 commented Oct 6, 2017

Hi @wswebcreation, was wondering if you had a chance to run my example? And I was curious to know what versions of protractor, cucumber, and protractor-cucumber-framework that you ran your example on?

@wswebcreation
Copy link
Contributor

Hi @gd46

Sorry for my late reaction. Was in Berlin for the Selenium Conf ;-).

I've checked it again and changed my local config to this

capabilities: {
    browserName: 'chrome',
    specs: '/Users/wswebcreation/contributions/e2e-tests/features/example.feature:7'
}

and it still works. I think you need to check your own code because it now looks like all is working as expected. Secondly because this is about using a third party framework I would advice checking protractor-cucumber-framework so I'm going to close this issue for now.

@gd46
Copy link
Author

gd46 commented Oct 14, 2017

No worries, thanks again I'll have another look.

@gd46
Copy link
Author

gd46 commented Oct 17, 2017

@wswebcreation can you take a look at this issue once more? There is a similar discussion in cucumber is but I think the issue is that the spec path that protractor cucumber framework ends up with is absolute and that's when I see it doesn't work.

cucumber/cucumber-js#924 (comment)

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

No branches or pull requests

4 participants