0

I am new in Cucumber and want to write optime code for 50 test cases. Every test case has different examples (set of test data flags) and different one when, different one then steps.

How can I write optimize Feature for above 2 test cases as I have to write similar for 50 test case?

Feature : have to automate one api

@tag1
scenario outline : scenario outline1
Given A
When B
When C
Then D
Then E

Examples:
|statusCode |payload|
|"200"      | "quantity:one;rollno:123;isStudent:true;isTeacher:true |  

@tag2
scenario outline : scenario outline2
Given A
When B
When X
Then D
Then Y

Examples:
|statusCode |payload|
|"200"      | "quantity:one;rollno:123;isStudent:false;isTeacher:false |

1 Answer 1

0

you can use the following code.

 Scenario Outline: Execute test case with specific flags
      Given the system is in "<initial state>"
      When I perform "<action>"
      Then I expect "<result>"
    
    Examples:
      | initial state  | action         | result              |
      | logged out     | login attempt  | login successful    |
      | logged in      | logout attempt | logout successful   |
      | logged in      | invalid action | error displayed     |
Sign up to request clarification or add additional context in comments.

2 Comments

Given A , When B and Then D is repetitive in above feature file which is mentioned in question. My query is how to define above statement once in feature file and use in every test case ?
it worked for me, thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.