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

Enhancement on Scenario Name. #40

Open
jacob-hanbeen-kim opened this issue Mar 18, 2020 · 1 comment
Open

Enhancement on Scenario Name. #40

jacob-hanbeen-kim opened this issue Mar 18, 2020 · 1 comment
Assignees
Milestone

Comments

@jacob-hanbeen-kim
Copy link

Current agent-js-cucumber only checks previous scenario name to create a unique name for the scenario (appending "[number]" after the scenario name) - guessing this was to account for scenarios with examples.

However, this will make some scenarios have same name if there are few other scenarios that have same name but not placed right after/before.

Example:

Scenario: Test
   Given this test has name Test

Scenario: Test2
   Given this test has name Test 2

Scenario: Test
   Given this test has name Test also

This will report to the reportportal as
Scenario: Test
Scenario: Test2
Scenario: Test

Possible/Proposed Fix:
Have a scenario name object that keeps track of what index to append to the end of the scenario name.

onTestCaseStarted(event) {
      context.scenario = findScenario(event.sourceLocation);
      const featureTags = findFeature(event.sourceLocation).tags;
      const pickle = pickleDocuments[getUri(event.sourceLocation.uri)];
      const keyword = context.scenario.keyword ? context.scenario.keyword : context.scenario.type;
      let name = [keyword, context.scenario.name].join(': ');
      const eventAttributes = pickle.tags
        ? pickle.tags
            .filter((tag) => !featureTags.find(createTagComparator(tag)))
            .map((tag) => createAttribute(tag.name))
        : [];
      const description =
        context.scenario.description ||
        [getUri(event.sourceLocation.uri), event.sourceLocation.line].join(':'); // TODO codeRef
      const { featureId } = pickleDocuments[event.sourceLocation.uri];

      if (!(name in context.scenariosName)) {
        context.scenariosName[name] = 1;
      // } else if (event.attemptNumber < 2) {
      } else {
        context.scenariosName[name] += 1;
        name += ` [${context.scenariosName[name]}]`;
      }

      // BeforeScenario
      // if (isScenarioBasedStatistics() || event.attemptNumber < 2) {
      context.scenarioId = reportportal.startTestItem(
        {
          name,
          startTime: reportportal.helpers.now(),
          type: isScenarioBasedStatistics() ? 'STEP' : 'TEST',
          description,
          attributes: eventAttributes,
          // retry: isScenarioBasedStatistics() && event.attemptNumber > 1,
        },
        context.launchId,
        featureId,
      ).tempId;
      // }
    }

**Note: that I commented out few codes that was causing me the bug I mentioned in #37

Above change will result in following report to the reportportal
Scenario: Test
Scenario: Test2
Scenario: Test [2]

@DzmitryHumianiuk
Copy link
Member

@AmsterGet what do you think?

@AmsterGet AmsterGet added this to the 5.0.0 milestone Aug 27, 2020
@AmsterGet AmsterGet linked a pull request Aug 27, 2020 that will close this issue
@AmsterGet AmsterGet modified the milestones: 5.0.0, 5.0.1 Aug 28, 2020
@AmsterGet AmsterGet removed a link to a pull request Aug 28, 2020
@AmsterGet AmsterGet modified the milestones: 5.0.1, 5.0.2 Oct 30, 2020
@AmsterGet AmsterGet modified the milestones: 5.0.2, 5.0.3 Aug 30, 2021
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

3 participants