Forum Discussion

NMeyer's avatar
NMeyer
Occasional Contributor
12 years ago

[Resolv.]Data-driven test with multiple logins exception ..

I have a data-driven test case that is attempting to login, test api a, test api b, logout, and then datasource loop back to login. The username and password for each login are coming from excel along with the api verification items for the api tests. The first time though the test case everything works fine, but after the datasource loop, every subsequent login fails with the following exception:

Fri Oct 11 09:08:12 EDT 2013:ERROR:java.io.IOException: Attempted read from closed stream.
java.io.IOException: Attempted read from closed stream.

I'm assuming this is due to the fact, that in order to get the test case to be successful, I had to enable the Maintain Http Session option, so all of the subsequent logins are attempting to login to a session that has already been logged off. Is there another setting that would enable me to maintain a unique session for each run through the datasource?

I attempted to modularize the test case by splitting our the login steps to their own test case and then call that from the main api test case (not 100% sure that would even fix my issue). In the event that this would fix my issue, I'd need to keep the datasource in the main api test case and then reference from the login test case using a groovy test script. I'm guessing I'd need to use context.expand to reference the datasource test step, but I'm not sure of the syntax for that.

Any help here would be much appreciated.

Thanks!