简体   繁体   中英

How do setUp and tearDown work for Load Testing with Jmeter and Junit?

I have to do some setup and cleanup on the database I am load testing with Jmeter and Junit. I have put these in setUp and tearDown respectively. My question now is what happens when I fire off 100 threads that execute my test? Will Jmeter first run 100 setUp's, then 100 threads of my test and then 100 tearDowns? Or does it just create 100 threads to execute my test and run them all in parallel?

My concern is just that the setUp and tearDown may affect my testing, depending on how Jmeter and Junit do things. In that case, I would have to do setUp and tearDown completely outside of my test.

I haven't used Junit and Jmeter together, so I'm assuming setUp and tearDown are part of Junit.

Given that, I would assume Junit would execute setUp, run the Jmeter script then run tearDown when Jmeter signals it is done. Since JMeter uses the same script for multiple threads, and isn't "done" until the last thread finishes, you shouldn't have multiple setUp/teardown Scripts.

I would try it with 2 threads and see what happens.

The time to perform the setUp and tearDown isn't taken into account when calculating the sampler's elapsed time. Only the execution time of the test method itself is measured - so from a reporting point of view it doesn't make any difference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM