1
votes

Yesterday, I started to write my first test cases with JMeter. Everything worked fine, but my test plan is growing and becomes messy. My problem is that I have a complicated login process with multiple HTTP calls which I need to do before each of my tests. The best way to re-use this login functionality I found so far is this:

enter image description here

I have a thread group (called Do the SAML Login) which is disabled. It contains two controllers which encapsulate the login and logout. Under that I have multiple thread groups for the actual tests (the screenshot only shows the first one). Each thread group starts and ends with an Once Only Controller to do the login and logout respectively. Between them are my actual test calls.

My problem is the following: I can execute my tests in a loop and all calls between my Once Only Controllers are executed multiple times while the login and logout is executed only once (cool!). But when I run with multiple threads, the login/logout is also done multiple times in threads.

How can I prevent this? I think I'm looking for some setup-up and tear-down method for my thread groups, but I don't know how to do it with JMeter.

1

1 Answers

1
votes

I would suggest moving your login and logout logic into setUp Thread Group and tearDown Thread Group correspondingly

You can use Test Fragments in combination with the Module Controller to re-use your login/logout login in multiple test plans.