Print thread groups including comments fields of underlying controllers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Print thread groups including comments fields of underlying controllers

Mathijs Groen
I have following question. I use JMeter as a tool for testing our internal API’s, from a functional point-of-view.

I use the comment fields for functionally describing the tests. Is it possible to print out all (a selection of) tests (‘Include Controllers’) including the Comments field on paper / to PDF?


Reply | Threaded
Open this post in threaded view
|

Re: Print thread groups including comments fields of underlying controllers

glinius@live.com
You can use  SearchByClass
<https://jmeter.apache.org/api/org/apache/jorphan/collections/SearchByClass.html>  
functions in order to fetch information on Include Controllers from the Test
Plan.

Here is an example with regards to how this can be done from JMeter test
itself using  JSR223 Sampler
<https://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler>  
and  Groovy <https://www.blazemeter.com/blog/groovy-new-black>  language :

 1. Add  tearDown Thread Group
<https://jmeter.apache.org/usermanual/component_reference.html#tearDown_Thread_Group>  
to your Test plan
 2. Add JSR223 Sampler to the tearDown Thread Group
 3. Put the following code into "Script" area:



> import org.apache.jmeter.engine.StandardJMeterEngine
> import  org.apache.jmeter.control.IncludeController
> import org.apache.jorphan.collections.HashTree
> import org.apache.jorphan.collections.SearchByClass
> import java.lang.reflect.Field
>
> StandardJMeterEngine engine = ctx.getEngine()
> Field test = engine.getClass().getDeclaredField("test")
> test.setAccessible(true)
> HashTree testPlanTree = (HashTree) test.get(engine)
>
> SearchByClass
> <IncludeController>
>  includeControllerSearch = new SearchByClass<>(IncludeController.class)
> testPlanTree.traverse(includeControllerSearch)
> Collection
> <IncludeController>
>  includeControllers = includeControllerSearch.getSearchResults()
> log.info('**************************************************')
> includeControllers.each {
>     log.info('Module: ' + it.getName() + ' Comments: ' + it.getComment())
> }
> log.info('**************************************************')



This way you will get the information on Include Controllers printed to
/jmeter.log/ file


<http://www.jmeter-archive.org/file/t340375/foo.png>

So you can either find the information in the jmeter.log file by searching
for the above asterisks or amend the code to be a standalone application and
create PDF using i.e.  Apache PDFBox <https://pdfbox.apache.org/>  , anyway
further steps are out of scope for this mailing list.




--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]