Search code examples
javajmeterbeanshell

Display success/Failure count in Swing Dialog box in Jmeter


enter image description here How to get the assertion result in JSR2233 Sampler or Beanshell Sampler,so that it would be helpful to show the total number of test case ,success test case ,failure test case in swing showMessageDialog, once testcase execution completed.


Solution

  • I am not really sure if I have understood question correctly!

    You seem to be using JMeter for functional testing which is fine! I assume that each request (or Sampler) is a test case. If the below answer is not really you were looking for, provide more info.

    setUp Thread Group:

    I create these 2 variables in a Beanshell Sampler.

    bsh.shared.success = 0;
    bsh.shared.fail = 0;
    

    Thread Group:

    I add the below code to update success / fail count based on the assertion result in a Beanshell Listener.

    if(sampleResult.isSuccessful()){
        bsh.shared.success++;
    }else{
        bsh.shared.fail++;
    }
    

    tearDown Thread Group:

    I finally display the Success and failed testcases count. You can use your Swing method here!

    log.info("PASSED : " + bsh.shared.success);
    log.info("FAILED : " + bsh.shared.fail);
    

    enter image description here