Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

java - How to use cucumber table when it is code driven

I want to use single row under examples in cucumber like below: Examples: | data1 | data2|paymentOp| | MySql | uk1 |??????????| Where paymentOp is a number which I am getting from java method which has List as an argument. The method returns each of the numbers which I want to pass it under paymentOp.

There is an absolute way to iterate it by copy the row and paste it again in the table but I don't want that because the method has a dynamic result which may return 2 or 5 set of numbers.

Is it possible to achieve it using Karate? How to proceed further. Any lead here would be much appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can combine Examples: with dynamic behavior. Please read this example (especially the second one): https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/outline/examples.feature

Since you have difficulties reading the docs and examples (:P) here is a simple example. Take some time to understand it carefully.

Background:
* def data = { one: 1, two: 2, three: 3 }

Scenario Outline:
* match data.<key> == <value>

Examples:
| key   | value |
| one   | 1     |
| two   | 2     |
| three | 3     |

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...