|
1 | 1 | (ns practitest-firecracker.eval |
2 | 2 | (:require |
3 | 3 | [clojure.string :as string] |
4 | | - [practitest-firecracker.query-dsl :refer [query? eval-query]] |
| 4 | + [practitest-firecracker.query-dsl :refer [query? eval-query read-query]] |
5 | 5 | [clojure.walk :refer [postwalk]] |
6 | | - [clojure.tools.logging :as log] |
7 | | - [practitest-firecracker.utils :refer [pformat]] |
8 | | - [practitest-firecracker.api :as api])) |
| 6 | + [practitest-firecracker.utils :refer [pformat replace-map replace-keys]] |
| 7 | + [practitest-firecracker.api :as api] |
| 8 | + [clojure.pprint :as pprint])) |
9 | 9 |
|
10 | 10 | (def custom-field-cache (atom {})) |
11 | 11 |
|
|
17 | 17 | (let [test-name (eval-query suite (:pt-test-name options))] |
18 | 18 | (if (string/blank? test-name) "UNNAMED" test-name))) |
19 | 19 |
|
| 20 | +(defn sf-test-case->pt-step-description [options test-case] |
| 21 | + (let [step-name (eval-query test-case (:pt-test-step-description options))] |
| 22 | + (if (string/blank? step-name) "UNNAMED" step-name))) |
| 23 | + |
20 | 24 | (defn sf-test-case->pt-step-name [options test-case] |
21 | 25 | (let [step-name (eval-query test-case (:pt-test-step-name options))] |
22 | 26 | (if (string/blank? step-name) "UNNAMED" step-name))) |
23 | 27 |
|
24 | 28 | (defn sf-test-case->step-def [options test-case] |
25 | | - {:name (sf-test-case->pt-step-name options test-case)}) |
| 29 | + {:name (sf-test-case->pt-step-name options test-case) |
| 30 | + :description (sf-test-case->pt-step-description options test-case)}) |
26 | 31 |
|
27 | 32 | (defn sf-test-suite->test-def [options test-suite] |
28 | 33 | [{:name (sf-test-suite->pt-test-name options test-suite)} |
|
100 | 105 | additional-testset-fields) |
101 | 106 | (map :id tests)))) |
102 | 107 |
|
103 | | -(defn sf-test-case->run-step-def [options test-case] |
104 | | - {:name (sf-test-case->pt-step-name options test-case) |
105 | | - :actual-results (str (:failure-message test-case) \newline (:failure-detail test-case)) |
106 | | - :status (case (:failure-type test-case) |
107 | | - :failure "FAILED" |
108 | | - :skipped "N/A" |
109 | | - :error "FAILED" |
110 | | - ;; will leave error as FAILED for now, will change it after we add the UI changes and add the option of ERROR to Reqirement Test and TestSet table of runs |
111 | | - nil "PASSED" |
112 | | - "NO RUN") |
113 | | - :description (:description test-case)}) |
114 | | - |
115 | | -(defn sf-test-suite->run-def [options test-suite] |
116 | | - [{:run-duration (:time-elapsed test-suite)} |
117 | | - (map (partial sf-test-case->run-step-def options) (:test-cases test-suite))]) |
| 108 | +(defn is-failed-step [only-failed-steps desc failure-detail] |
| 109 | + (or (not only-failed-steps) |
| 110 | + (and |
| 111 | + (not (nil? failure-detail)) |
| 112 | + (not (nil? desc)) |
| 113 | + (string/includes? failure-detail desc)))) |
| 114 | + |
| 115 | +(defn sf-test-case->run-step-def [options params test-suite-cases test-case] |
| 116 | + (let [grouped-case (group-by (fn [case] (sf-test-case->pt-step-description options case)) test-suite-cases) |
| 117 | + description (or (:description test-case) (sf-test-case->pt-step-description options test-case)) |
| 118 | + new-desc (replace-map description (replace-keys params)) |
| 119 | + origin-case (first (get grouped-case new-desc)) |
| 120 | + msg (str (or (:failure-message origin-case) (:failure-message test-case)) \newline (:failure-detail test-case))] |
| 121 | + {:name (if (nil? (:position test-case)) |
| 122 | + (sf-test-case->pt-step-name options test-case) |
| 123 | + (or (:pt-test-step-name test-case) |
| 124 | + (sf-test-case->pt-step-name options test-case))) |
| 125 | + :description new-desc |
| 126 | + :actual-results (when (is-failed-step (:only-failed-steps options) new-desc msg) msg) |
| 127 | + :status (case (when (is-failed-step (:only-failed-steps options) new-desc (:failure-detail test-case)) (:failure-type test-case)) |
| 128 | + :failure "FAILED" |
| 129 | + :skipped "N/A" |
| 130 | + :error "FAILED" |
| 131 | + ;; will leave error as FAILED for now, will change it after we add the UI changes and add the option of ERROR to Reqirement Test and TestSet table of runs |
| 132 | + nil "PASSED" |
| 133 | + "NO RUN")})) |
| 134 | + |
| 135 | +(defn sf-test-suite->run-def [options test-suite sys-test params] |
| 136 | + [{:run-duration (:time-elapsed sys-test)} |
| 137 | + (map (partial sf-test-case->run-step-def options params (:test-cases test-suite)) |
| 138 | + (sort-by :position (:test-cases sys-test)))]) |
118 | 139 |
|
119 | 140 | (defn sf-test-run->run-def [custom-fields run-duration] |
120 | 141 | {:run-duration (:time-elapsed run-duration), |
|
0 commit comments