I want to write JMeter requests in Java. I found some examples by googling but I am not understanding how to assert the response i.e. the way we use Response Assertion to check whether the page was loaded successfully or not. Please share step-by-step process for JMeter with java coding.

closed as too broad by corsiKa Jan 8 '16 at 16:35

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Something like this masudqa.blogspot.com/2014/06/… ? – demouser123 Aug 11 '15 at 2:22
  • This style question is unlikely to produce quality answers. Instead, make an attempt and let us know what fails. And at this point if it's still a problem, might want to make a new question too. =) – corsiKa Jan 8 '16 at 16:35

You can take a look at 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide to learn how to run existing JMeter test scenario from Java code and how to create a JMeter test purely in Java.

Also refer jmeter-from-code snippet for working example.

In regards to implementing assertions, you can create a simple test plan i.e. having one request and one assertion, load it via SaveService.loadTree() method and inspect resulting HashTree to see how does it look under the hood.

  • Very interesting link. It is a bit annoying (probably I am missing it) that there are around the web quite a few ways about how to prepare and run testplans but there is not much about how to get the results if you are trying to use the Java API for JMeter. I understand this might be quite a specific need. – Giuseppe May 16 at 14:32

Please refer the below link. Thought this might work. https://javaworks.wordpress.com/2013/06/28/beanshell-assertion-in-jmeter/

  • Thanks for your answer @SundarsCorp, But I want with pure java code – QAMember Jun 10 '15 at 14:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.