Variables not resetting as expected
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?