Variables not resetting as expected
Good afternoon,
Recently I encountered some unexpected behavior while iterating through an excel data source. The scenario plays out like this:
- Excel Datasource. Range 1-3
- Test 1: Authenticate
2.1. Traffic object. Groovy extract session token and context.setValue("var_token", token) - Test 2: GetAccountInfo. Passing var_token in the header.
- Row 1 has a valid username/password and passes all tests.
- Row 2 has an INVALID username/password and fails to extract the token. At this point I would expect the variable to reset to the default 0, but instead, it is still using the token gathered from the first datasource row and sends the request.
I call this behavior unexpected because I thought everything ran sequentially and when data row 1 was complete it would reset all variables back to their default state because it starts executing from the top of the list again (where the variable is set to default 0). To get past this, I updated my script to perform a context.setValue("var_token", "0").
Is this expected behavior or did I uncover a flaw?
Thanks!
Comments
-
when data row 1 was complete it would reset all variables back to their default state
The behavior is by design. Values you write to the Context from a script are completely independent of data source row usage. They are not scoped to a particular data source row, nor the test suite where you happened to set them in.
1