Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Variables not resetting as expected

Options
Gambit
Gambit Posts: 28
edited January 2018 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_parasoft
    benken_parasoft Posts: 1,230 ✭✭✭
    Options

    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.