Skip to content

Commit 9f72887

Browse files
committed
process: test case and suite totalSteps variables added to address #808
Signed-off-by: Ivan Velasco <[email protected]>
1 parent aae6f3a commit 9f72887

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

process_testcase.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func (v *Venom) runTestCase(ctx context.Context, ts *TestSuite, tc *TestCase) {
139139
tc.Vars = ts.Vars.Clone()
140140
tc.Vars.Add("venom.testcase", tc.Name)
141141
tc.Vars.AddAll(ts.ComputedVars)
142+
tc.Vars.Add("venom.testcase.totalSteps", len(tc.RawTestSteps))
142143
tc.computedVars = H{}
143144

144145
ctx = v.processSecrets(ctx, ts, tc)
@@ -185,10 +186,13 @@ func (v *Venom) runTestSteps(ctx context.Context, tc *TestCase, tsIn *TestStepRe
185186
fromUserExecutor := tsIn != nil
186187

187188
loopRawTestSteps:
188-
for stepNumber, rawStep := range tc.RawTestSteps {
189+
for stepIndex, rawStep := range tc.RawTestSteps {
189190
stepVars := tc.Vars.Clone()
190191
stepVars.AddAll(previousStepVars)
191192
stepVars.AddAllWithPrefix(tc.Name, tc.computedVars)
193+
194+
// Use stepNumber as a 1-based index
195+
stepNumber := stepIndex + 1
192196
stepVars.Add("venom.teststep.number", stepNumber)
193197

194198
ranged, err := parseRanged(ctx, rawStep, stepVars)

process_testsuite.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ func (v *Venom) runTestSuite(ctx context.Context, ts *TestSuite) error {
6161

6262
totalSteps := 0
6363
for _, tc := range ts.TestCases {
64-
totalSteps += len(tc.testSteps)
64+
totalSteps += len(tc.RawTestSteps)
6565
}
6666

67+
ts.Vars.Add(("venom.testsuite.totalSteps"), totalSteps)
6768
ts.Status = StatusRun
6869
Info(ctx, "With secrets in testsuite")
6970
for _, v := range ts.Secrets {
@@ -218,7 +219,7 @@ func (v *Venom) parseTestCases(ts *TestSuite) ([]string, []string, error) {
218219
for i := range ts.TestCases {
219220
tc := &ts.TestCases[i]
220221
tc.originalName = tc.Name
221-
tc.number = i
222+
tc.number = i + 1
222223
tc.Name = slug.Make(tc.Name)
223224
tc.Vars = ts.Vars.Clone()
224225
tc.Vars.Add("venom.testcase", tc.Name)

0 commit comments

Comments
 (0)