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

[GPC] Sorter #52

Closed
gula123 opened this issue Feb 7, 2021 · 1 comment
Closed

[GPC] Sorter #52

gula123 opened this issue Feb 7, 2021 · 1 comment

Comments

@gula123
Copy link

gula123 commented Feb 7, 2021

Summary

The precompiler would sort the elements of the feature files by a selected tag(s).

Use cases

If switching between different groups of scenarios require extra steps, a customizable sorter could group similar scenarios so less switch would be needed.
For example, if switching between admin and standard user scenarios needs logout-login to actually switch the user, we could group all admin scenarios in one group and all standard user scenarios into another, thus only a single logout-login should be applied.

Example

Take the following (example) feature file:

# src/simple.feature
Feature: Simple feature

  @user(admin)
  Scenario: Admin cases 1
    Given the XY page is opened with an admin user
    When I select an entity
    Then Option to delete the entity should be visible

  @user(standard)
  Scenario: Standard user cases 1
    Given the XY page is opened with a standard user #First Logout-login
    When I select an entity
    Then Option to delete the entity should not be visible

  @user(admin)
  Scenario: Admin cases 2
    Given the YX page is opened #Second Logout-login
    When I click on the Settings icon
    Then admin view should be visible

  @user(standard)
  Scenario: Standard user cases 2
    Given the YX page is opened #Third Logout-login
    When I click on the Settings icon
    Then simple view should be visible

Running the precompiled sorted based on @user tag would result in the following feature file:

# dist/simple.feature
Feature: Simple feature

  @sort(admin)
  Scenario: Admin cases 1
    Given the XY page is opened with an admin user
    When I select an entity
    Then Option to delete the entity should be visible

  @user(admin)
  Scenario: Admin cases 2
    Given the YX page is opened
    When I click on the Settings icon
    Then admin view should be visible

  @user(standard)
  Scenario: Standard user cases 1
    Given the XY page is opened with a standard user #Logout-login only occurs here
    When I select an entity
    Then Option to delete the entity should not be visible

  @user(standard)
  Scenario: Standard user cases 2
    Given the YX page is opened
    When I click on the Settings icon
    Then simple view should be visible

Options/Variants

  • Sort ascending/descending
  • Being able to sort based on multiple tags. E.g. We could configure it to sort scenarios primarily based on @user(xy) tags, and in case two scenarios have identical user tags, we could further sort them based on @otherTag(yz)

Additional context

@szikszail szikszail changed the title gpc-sorter [GPC] Sorter Feb 2, 2022
@szikszail
Copy link
Collaborator

@gula123, how would you handle a scenario with multiple sorting tags?

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

2 participants