Skip to content

Commit fce53cb

Browse files
authored
Merge pull request #32 from PractiTest/bugfix/PT1-3160-fix-examples-outline
Fixed issues in BDD support
2 parents 9b04f93 + da5a3aa commit fce53cb

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

src/practitest_firecracker/parser/gherkin.clj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
(defn- expand-scenario-outline
3737
[scenario feature]
3838
(let [examples (:examples scenario)
39-
all-params (glue-example-arguments (first examples))]
39+
all-params (mapcat glue-example-arguments examples)]
4040
(mapcat
4141
(fn [param]
4242
;; Store params and values here for future reference
@@ -58,6 +58,9 @@
5858
(:map param)] result]]))
5959
all-params)))
6060

61+
(defn- examples-section-end? [line]
62+
(str/starts-with? (str/lower-case (str/trim line)) "scenario:"))
63+
6164
;; TODO: tags support ??
6265
(defn- extract-scenario-source
6366
[feature-root scenario]
@@ -73,13 +76,13 @@
7376

7477
outline?
7578
;; For outline need to extract examples as well
76-
(let [start-examples (:line (:location (last (:examples scenario))))]
77-
;; Find end of examples sections - either end of file or empty line
79+
(let [start-examples (:line (:location (first (:examples scenario))))]
80+
;; Find end of examples sections - either end of file or new BDD scenario
7881
(loop [i start-examples
7982
coll (seq (drop start-examples feature-source))]
8083
(if coll
8184
(let [line (first coll)]
82-
(if (str/blank? line)
85+
(if (examples-section-end? line)
8386
i
8487
(recur (inc i) (next coll))))
8588
i)))

src/practitest_firecracker/practitest.clj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,16 @@
319319
(when display-action-logs (log/infof "make-runs"))
320320
(flatten (doall
321321
(for [[test-testset instances] instance-to-ts-test]
322-
(map-indexed
323-
(fn [index instance]
322+
(map
323+
(fn [instance]
324324
(let [[_ test-id] test-testset
325325
tst (first (get test-by-id test-id))
326326
test-name (get tst 0)
327-
params (get test-name-to-params test-name)
328-
this-param (get params index)
327+
this-param (:parameters (:attributes instance))
328+
;; Use nil in case of empty params
329+
this-param (if (empty? this-param)
330+
nil
331+
this-param)
329332
xml-test (get group-xml-tests [test-name this-param])
330333
sys-test (get tst 1)
331334
[run run-steps] (eval/sf-test-suite->run-def options (first xml-test) sys-test this-param)

test/gherkin/identity.feature

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ Feature: Identity feature
33
Given I run identity function with 1
44
Then I will get result 1
55

6-
Scenario Outline: Multiple identity tests for <arg> and <result> with "Some quoutes"
7-
When I run identity function with <arg>
8-
Then I will get result <result> every time
6+
Scenario Outline: Multiple identity tests for <First Arg> and <Second Arg> with "Some quoutes"
7+
When I run identity function with <First Arg>
8+
Then I will get result <Second Arg> every time
99

1010
Examples:
11-
| arg | result |
11+
12+
| First Arg | Second Arg |
1213
| "First Item" | "First Item" |
13-
| "Second Item" | "Second 123" |
14+
| "Second Item" | "Second 123" |
1415
| "Third Item" | "Third Item" |
16+
17+
Examples:
18+
19+
| First Arg | Second Arg |
20+
| "Second Part" | "Second Part" |
21+
| "Failure" | "That would fail" |
22+
23+
Scenario: Another schenario just in case

0 commit comments

Comments
 (0)