If you are starting your career as a Performance Test Engineer, you will be dealing with lots of login flows during your working hours. Since it is really important for the sake of your load test, the login page should be tested thoroughly. Here are some tips for you to create and execute a proper test to test login page using JMeter.
1. Practice Login Flow Manually
Before recording the requests for login flow, you should perform a couple of manual tests for login components. Make sure that the login button, user credential sections and other basic functions work as expected and you don’t face any kind of bug that will block the load test. After this process, you can continue with recording the flow and writing the script.
2. Don’t Forget to Extract Token and Other Important Data
A login service usually has a response message that contains a token. To be able to create the rest of the script properly, you should extract this token and use it in your other requests. There can also be some other important data in responses. You should check them.
3. Make Your Login Data Dynamic
A load test usually requires thousands of threads (concurrent users) for your system under test. If we are talking about the test of a login page, it is very possible that we need to have thousands of login credentials as well. So now your question might be “How to pass username and password in JMeter?” To make these credentials dynamic and accessible for our threads, we use CSV files on JMeter.
By using CSV data, you can send dynamic and unique values for your threads and request parameters. Also with this method, you can easily change the values of your requests parameters later on.
4. Add Assertions
If it is possible, you should create assertions for every request in your load test script. But as the login part is the heart of your test flow, an assertion should definitely be contained in your login request.
With these assertions, you can make sure that everything goes well with login requests and the rest of the test should be continued properly.
5. Think About Using Cookie Manager
Your load test script can have multiple iterations for your threads. But sometimes, you might want your threads to act like a new user between iterations. To do this, you can add HTTP Cookie Manager and enable the option named “Clear cookies each iteration”.
If your responses contain a cookie that should be used between requests, Cookie Manager can do this for you. When it is added to load test script, Cookie Manager automatically stores cookies and will use it for all future requests.