I am working on a test plan for our REST web application and we have several common test types which have common criteria we want to test for. For example, when creating entities through the API we have a common set of expectations for the JSON response; id should be set, created date should be set, etc.
Now, I would like to model my plans like this:
- Thread Group
- Users (Simple Controller)
- User Create Tests (Simple Controller)
- Create Test 1 (Sampler)
- Create Test 2 (Sampler)
- Create Test 3 (Sampler)
- Common Creation Asserts (Module Controller)
- User Delete Tests (Simple Controller)
- Samplers...
- Common Delete Asserts (Module Controller)
- User Create Tests (Simple Controller)
- Events (Simple Controller)
- Event Create Tests (Simple Controller)
- Samplers...
- Common Creation Asserts (Module Controller)
- Event Delete Tests (Simple Controller)
- Samplers...
- Common Delete Asserts (Module Controller)
- Event Create Tests (Simple Controller)
- Users (Simple Controller)
- Thread Group for common assertions (disabled)
- Common Creation Assertions (Simple Controller)
- BSF Assertion 1
- BSF Assertion 2
- BSF Assertion 3
- Common Delete Assertions (Simple Controller)
- Asserts...
- Common Creation Assertions (Simple Controller)
Now, I understand how the scoping works and that if I placed assertions where the BOLDed module controllers are they would be invoked for each sampler. However, I'd rather not have to copy-paste-maintain numerous copies of the same assertions in each of these locations. Hence, why I want a way to define assertions once, and invoke where appropriate.
However, with this approach, the ACCENTed assertions placed in the common simple controllers are never invoked (confirmed by using a BSF assertion with logging messages). If I place an additional sampler in the common assertions simple controller it is invoked. But only a single time.
I'm using JMeter 2.12 but have confirmed that JMeter 2.8 behaves the same way.
So, how can I use JMeter to define assertions once, and re-use them anywhere?
Thanks!