Cucumber: usage file in scenario

fashuser

I have the following scenario:

Feature: Some feature
   Scenario: Test feature
     Given login as test_user
     When test_user submits changes with content:
        """
        Very long text
        """
     Then content is saved

The main goal is to move the "very long text" to some file or something like this and avoid duplication of this text in the defined scenarios.

user1459144

I see only one solution (this solution isn't so nice, but can be used as alternative):

Feature: Some feature
   Scenario: Test feature
     Given login as test_user
     When test_user submits changes with content very_long_text.txt            
     Then content is saved

And put very_long_text.txt in the project test resources. Separate folder can be created to hold all cucumber resources. As example: src/test/resources/cucumber

And create Utility class that read content of this resource:

public static String getText(String fileName){
    IOUtils.toString("cucumber" + fileName);
}

And use the file content in that way. In order to do not duplicate messages in the code

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

cucumber: how to run specific scenario from a feature file

From Dev

Can't get a scenario's filename from scenario.file in Cucumber 2.3.2

From Dev

Can't get a scenario's filename from scenario.file in Cucumber 2.3.2

From Dev

Cucumber and capybara scenario session

From Dev

Cucumber and capybara scenario session

From Dev

Handling cucumber scenario examples as one scenario

From Dev

Taking a screenshot on failed scenario Cucumber

From Dev

Running cucumber scenario outline in parallel

From Dev

Cucumber scenario assert condition in DataTable

From Java

Error running Scenario please specify package correctly: "../null" file not found - Cucumber/CodeceptJs/IntelliJ

From Dev

Display TimeStamp (Start Time/End Time) for each of the Test Scenario in Cucumber Report (.html/.json) file

From Dev

Liquibase scenario, initial usage

From Dev

Can we call one scenario inside another scenario in cucumber?

From Dev

Is there a way to make cucumber try a scenario again before moving on to the next scenario

From Dev

Is there a way to make cucumber try a scenario again before moving on to the next scenario

From Dev

Use the same examples in multiple Cucumber scenario outlines

From Dev

How to get name of scenario in cucumber java?

From Dev

Determine if a cucumber scenario has pending steps

From Dev

Ruby cucumber scenario hook execution order

From Dev

How to trace fail scenario in cucumber for test environment?

From Dev

Cucumber scenario outline and examples with generic step definitions

From Dev

How do I "skip" a scenario with a tag in Cucumber?

From Dev

Get Status from Scenario with Cucumber 2.0.0

From Dev

Run Cucumber scenario outline by range on line numbers

From Dev

Handling excel spreadsheets with Cucumber Scenario Outline

From Dev

How to trace fail scenario in cucumber for test environment?

From Dev

Get Status from Scenario with Cucumber 2.0.0

From Dev

Is there any cucumber command to get all the scenario names?

From Dev

Cucumber reuse value from previously run scenario

Related Related

  1. 1

    cucumber: how to run specific scenario from a feature file

  2. 2

    Can't get a scenario's filename from scenario.file in Cucumber 2.3.2

  3. 3

    Can't get a scenario's filename from scenario.file in Cucumber 2.3.2

  4. 4

    Cucumber and capybara scenario session

  5. 5

    Cucumber and capybara scenario session

  6. 6

    Handling cucumber scenario examples as one scenario

  7. 7

    Taking a screenshot on failed scenario Cucumber

  8. 8

    Running cucumber scenario outline in parallel

  9. 9

    Cucumber scenario assert condition in DataTable

  10. 10

    Error running Scenario please specify package correctly: "../null" file not found - Cucumber/CodeceptJs/IntelliJ

  11. 11

    Display TimeStamp (Start Time/End Time) for each of the Test Scenario in Cucumber Report (.html/.json) file

  12. 12

    Liquibase scenario, initial usage

  13. 13

    Can we call one scenario inside another scenario in cucumber?

  14. 14

    Is there a way to make cucumber try a scenario again before moving on to the next scenario

  15. 15

    Is there a way to make cucumber try a scenario again before moving on to the next scenario

  16. 16

    Use the same examples in multiple Cucumber scenario outlines

  17. 17

    How to get name of scenario in cucumber java?

  18. 18

    Determine if a cucumber scenario has pending steps

  19. 19

    Ruby cucumber scenario hook execution order

  20. 20

    How to trace fail scenario in cucumber for test environment?

  21. 21

    Cucumber scenario outline and examples with generic step definitions

  22. 22

    How do I "skip" a scenario with a tag in Cucumber?

  23. 23

    Get Status from Scenario with Cucumber 2.0.0

  24. 24

    Run Cucumber scenario outline by range on line numbers

  25. 25

    Handling excel spreadsheets with Cucumber Scenario Outline

  26. 26

    How to trace fail scenario in cucumber for test environment?

  27. 27

    Get Status from Scenario with Cucumber 2.0.0

  28. 28

    Is there any cucumber command to get all the scenario names?

  29. 29

    Cucumber reuse value from previously run scenario

HotTag

Archive