Skip to main content

JMeter as Code (with FitNesse)

Try to execute the JMeter test script (the JMX file) in FitNesse.

1. Create a JMX file.

2. Create a Java class aim for FitNesse test. Extending ColumnFixture (http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.FitFramework.ColumnFixture) for its ease of use.

3. Since JMeter does not stored the Assertion Result,
create a SamplerListener class extending Visualizer (https://jmeter.apache.org/api/org/apache/jmeter/visualizers/Visualizer.html) and
add to all the ResultCollector (https://jmeter.apache.org/api/org/apache/jmeter/reporters/ResultCollector.html)
with #setListener method (https://jmeter.apache.org/api/org/apache/jmeter/reporters/AbstractListenerElement.html#setListener-org.apache.jmeter.visualizers.Visualizer-).
The SamplerListener#isAllAssertionPassed will return false when there is any sampler evaluated as false (either error or failure).
e.g.
SearchByClass samplerSearch = new SearchByClass(ResultCollection.class);
testPlanHashTree.traverse(samplerSearch);
Collection samplers  = samplerSearch.getSearchResults();
for (ResultCollection sampler : samplers.toArray()[0]) {
        sampler.setListener(samplerListener);
}

Notes:
for easier debug, can modify the sampler output file path to the FitNesse environment that the details sampler output can be downloaded from FitNesse directly.

4. Prepare a jmeter.properties to be used by JMeter runtime under FitNesse environment.

5. Add a Test in FitNesse, i.e.
| !Test.JMeterTest |
| propertyFilePath | jmxFilePath | isAllAssertionPassed? |
| /tmp/jmeter.properties | /tmp/jmeter-test.jmx | true |


Reference

  1. A Test Developer's blog: Jmeter, https://shantonusarker.blogspot.com/p/jmeter.html .
  2. Selenium with FitNesse – Acceptance testing Framework – Assert Selenium, 2012 Nov 10, http://www.assertselenium.com/atdd/selenium-fitnesse/ .
  3. How to Use JMeter Assertions in Three Easy Steps, BlazeMeter, 2016 Jun 10, https://www.blazemeter.com/blog/how-use-jmeter-assertions-3-easy-steps .


Comments

Popular posts from this blog

人間好時節

春有百花秋有月 夏有涼風冬有雪 若無閒事掛心頭 便是人間好時節 本星期十常八 九之事比較多, 心情較為低沉. 此時最住解決方案就是做好本份, 好好學習同常想一二.

Novel

 全球異能:開局覺醒紫霄神雷章節列表 - 稷下書院 https://www.novel543.com/1215500675/ 御獸時代,我開局神級天賦 https://www.novel543.com/1001497097/ 混沌天帝决 https://t.shuqi.com/book/7978589.html