Variables not resetting as expected

GambitGambit Posts: 8
edited January 23 in SOAtest

Good afternoon,

Recently I encountered some unexpected behavior while iterating through an excel data source. The scenario plays out like this:

  1. Excel Datasource. Range 1-3
  2. Test 1: Authenticate
    2.1. Traffic object. Groovy extract session token and context.setValue("var_token", token)
  3. 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!

Tagged:

Comments

  • benken_parasoftbenken_parasoft Posts: 399 ✭✭✭

    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.

Sign In or Register to comment.