@@ -11,9 +11,11 @@ const countTests = ({
11
11
} ) => {
12
12
const countScenarioResult = scenarioResult => {
13
13
return (
14
- scenarioResult ?. assertionResults ?. every (
14
+ ( scenarioResult ?. assertionResults ?. every (
15
15
assertionResult => assertionResult . passed
16
- ) || 0
16
+ ) &&
17
+ scenarioResult . unexpectedBehaviors . length === 0 ) ||
18
+ 0
17
19
) ;
18
20
} ;
19
21
@@ -33,6 +35,24 @@ const countTests = ({
33
35
return countScenarioResult ( scenarioResult ) ;
34
36
} ;
35
37
38
+ const countAvailableData = (
39
+ countScenarioResult ,
40
+ { testPlanReport, testResult, scenarioResult }
41
+ ) => {
42
+ const countTestResult = testResult => {
43
+ return sum ( testResult ?. scenarioResults ?. map ( countScenarioResult ) || [ ] ) ;
44
+ } ;
45
+ const countTestPlanReport = testPlanReport => {
46
+ return sum (
47
+ testPlanReport ?. finalizedTestResults ?. map ( countTestResult ) || [ ]
48
+ ) ;
49
+ } ;
50
+
51
+ if ( testPlanReport ) return countTestPlanReport ( testPlanReport ) ;
52
+ if ( testResult ) return countTestResult ( testResult ) ;
53
+ return countScenarioResult ( scenarioResult ) ;
54
+ } ;
55
+
36
56
const countAssertions = ( {
37
57
testPlanReport, // Choose one to provide
38
58
testResult, // Choose one to provide
@@ -77,47 +97,33 @@ const countAssertions = ({
77
97
if ( passedOnly ) return all . filter ( each => each . passed ) . length ;
78
98
return all . length ;
79
99
} ;
80
- const countTestResult = testResult => {
81
- return sum ( testResult ?. scenarioResults ?. map ( countScenarioResult ) || [ ] ) ;
82
- } ;
83
- const countTestPlanReport = testPlanReport => {
84
- return sum (
85
- testPlanReport ?. finalizedTestResults ?. map ( countTestResult ) || [ ]
86
- ) ;
87
- } ;
88
-
89
- if ( testPlanReport ) return countTestPlanReport ( testPlanReport ) ;
90
- if ( testResult ) return countTestResult ( testResult ) ;
91
- return countScenarioResult ( scenarioResult ) ;
100
+ return countAvailableData ( countScenarioResult , {
101
+ testPlanReport,
102
+ testResult,
103
+ scenarioResult
104
+ } ) ;
92
105
} ;
93
106
94
107
const countUnexpectedBehaviors = ( {
95
- scenarioResult , // Choose one to provide
108
+ testPlanReport , // Choose one to provide
96
109
testResult, // Choose one to provide
97
- testPlanReport // Choose one to provide
110
+ scenarioResult // Choose one to provide
98
111
} ) => {
99
112
const countScenarioResult = scenarioResult => {
100
113
return scenarioResult ?. unexpectedBehaviors ?. length || 0 ;
101
114
} ;
102
- const countTestResult = testResult => {
103
- return sum ( testResult ?. scenarioResults ?. map ( countScenarioResult ) || [ ] ) ;
104
- } ;
105
- const countTestPlanReport = testPlanReport => {
106
- return sum (
107
- testPlanReport ?. finalizedTestResults ?. map ( countTestResult ) || [ ]
108
- ) ;
109
- } ;
110
-
111
- if ( testPlanReport ) return countTestPlanReport ( testPlanReport ) ;
112
- if ( testResult ) return countTestResult ( testResult ) ;
113
- return countScenarioResult ( scenarioResult ) ;
115
+ return countAvailableData ( countScenarioResult , {
116
+ testPlanReport,
117
+ testResult,
118
+ scenarioResult
119
+ } ) ;
114
120
} ;
115
121
116
122
const countUnexpectedBehaviorsImpact = (
117
123
{
118
- scenarioResult , // Choose one to provide
124
+ testPlanReport , // Choose one to provide
119
125
testResult, // Choose one to provide
120
- testPlanReport // Choose one to provide
126
+ scenarioResult // Choose one to provide
121
127
} ,
122
128
impact
123
129
) => {
@@ -126,40 +132,26 @@ const countUnexpectedBehaviorsImpact = (
126
132
? 1
127
133
: 0 ;
128
134
} ;
129
- const countTestResult = testResult => {
130
- return sum ( testResult ?. scenarioResults ?. map ( countScenarioResult ) || [ ] ) ;
131
- } ;
132
- const countTestPlanReport = testPlanReport => {
133
- return sum (
134
- testPlanReport ?. finalizedTestResults ?. map ( countTestResult ) || [ ]
135
- ) ;
136
- } ;
137
-
138
- if ( testPlanReport ) return countTestPlanReport ( testPlanReport ) ;
139
- if ( testResult ) return countTestResult ( testResult ) ;
140
- return countScenarioResult ( scenarioResult ) ;
135
+ return countAvailableData ( countScenarioResult , {
136
+ testPlanReport,
137
+ testResult,
138
+ scenarioResult
139
+ } ) ;
141
140
} ;
142
141
143
142
const countCommands = ( {
144
- scenarioResult , // Choose one to provide
143
+ testPlanReport , // Choose one to provide
145
144
testResult, // Choose one to provide
146
- testPlanReport // Choose one to provide
145
+ scenarioResult // Choose one to provide
147
146
} ) => {
148
147
const countScenarioResult = scenarioResult => {
149
148
return scenarioResult ?. scenario ?. commands ?. length ? 1 : 0 ;
150
149
} ;
151
- const countTestResult = testResult => {
152
- return sum ( testResult ?. scenarioResults ?. map ( countScenarioResult ) || [ ] ) ;
153
- } ;
154
- const countTestPlanReport = testPlanReport => {
155
- return sum (
156
- testPlanReport ?. finalizedTestResults ?. map ( countTestResult ) || [ ]
157
- ) ;
158
- } ;
159
-
160
- if ( testPlanReport ) return countTestPlanReport ( testPlanReport ) ;
161
- if ( testResult ) return countTestResult ( testResult ) ;
162
- return countScenarioResult ( scenarioResult ) ;
150
+ return countAvailableData ( countScenarioResult , {
151
+ testPlanReport,
152
+ testResult,
153
+ scenarioResult
154
+ } ) ;
163
155
} ;
164
156
165
157
const calculateAssertionPriorityCounts = ( result , priority ) => {
0 commit comments