@@ -24,7 +24,7 @@ type Runner struct {
24
24
// Map to track processed hooks to prevent infinite recursion
25
25
processedHooks map [string ]bool
26
26
// Mutex to protect the processed hooks map
27
- hooksMutex sync.Mutex
27
+ hooksMutex sync.Mutex
28
28
}
29
29
30
30
func NewRunner (opts * TestRunnerOptions ) TestRunner {
@@ -241,7 +241,14 @@ func (r *Runner) executeTestDefinition(def *tests.TestDefinition) (tests.TestDef
241
241
Suites : make (map [string ]tests.TestSuiteResult , len (def .Suites )),
242
242
}
243
243
244
+ // Process environment variables in variable values
245
+ if err := tests .InterpolateVariableValues (def .Variables ); err != nil {
246
+ r .Logger .Error ("Error interpolating environment variables in definition variables" , zap .Error (err ))
247
+ // Continue execution despite interpolation errors
248
+ }
249
+
244
250
r .Logger .Debug (fmt .Sprintf ("executing test definition: %s" , def .Name ))
251
+ r .Logger .Debug ("test definition variables" , zap .Any ("variables" , def .Variables ))
245
252
246
253
// Execute BeforeAll hooks if they exist
247
254
if len (def .BeforeAll ) > 0 {
@@ -268,14 +275,20 @@ func (r *Runner) executeTestDefinition(def *tests.TestDefinition) (tests.TestDef
268
275
269
276
// Create a copy of definition variables for the suite
270
277
suiteVars := make (map [string ]tests.Variable )
271
-
278
+
272
279
// First add definition-level variables
273
280
for k , v := range def .Variables {
274
281
suiteVars [k ] = v
275
282
}
276
-
283
+
277
284
// Then add suite-level variables (to override any definition variables with the same name)
278
285
if suite .Variables != nil {
286
+ // First process environment variables in suite-level variable values
287
+ if err := tests .InterpolateVariableValues (suite .Variables ); err != nil {
288
+ r .Logger .Error ("Error interpolating environment variables in suite variables" , zap .Error (err ))
289
+ // Continue execution despite interpolation errors
290
+ }
291
+
279
292
for k , v := range suite .Variables {
280
293
suiteVars [k ] = v
281
294
}
@@ -298,12 +311,13 @@ func (r *Runner) executeTestDefinition(def *tests.TestDefinition) (tests.TestDef
298
311
}
299
312
300
313
// Set up the suite with variables
301
-
302
314
// Pass variables to suite
303
315
suite .Variables = suiteVars
304
316
305
317
// Execute the test suite
306
318
r .Logger .Debug (fmt .Sprintf ("executing test suite: %s" , suite .Name ))
319
+ r .Logger .Debug ("suite variables" , zap .Any ("variables" , suite .Variables ))
320
+
307
321
suiteResult , err := suite .Run (r .Logger , r .HttpClient )
308
322
if err != nil {
309
323
r .Logger .Error ("error executing test suite" , zap .Error (err ))
0 commit comments