background image
<< Step-by-step Usage | Access log sampler Step-by-step >>

JMeter runs multi-threaded

<< Step-by-step Usage | Access log sampler Step-by-step >>
Here are some general guidelines for writing Junit tests so they work well with Jmeter. Since
Jmeter runs multi-threaded, it is important to keep certain things in mind.
1. Write the setUp and tearDown methods so they are thread safe. This generally means
avoid using static memebers.
2. Make the test methods discrete units of work and not long sequences of actions. By
keeping the test method to a descrete operation, it makes it easier to combine test
methods to create new test plans.
3. Avoid making test methods depend on each other. Since Jmeter allows arbitrary
sequencing of test methods, the runtime behavior is different than the default Junit
behavior.
4. If a test method is configurable, be careful about where the properties are stored. Reading
the properties from the Jar file is recommended.
5. Each sampler creates an instance of the test class, so write your test so the setup happens
in oneTimeSetUp and oneTimeTearDown.
6. If you select a class and no methods show up, it means the sampler had a problem
creating an instance of the test class. The best way to debug this is to add some
System.out to your class constructor and see what is happening.