JMeter - Ignore View Results Tree Listener only in non GUI

后端 未结 1 1553
轮回少年
轮回少年 2021-01-14 22:00

Important best practice in not to use View Results Tree

Don\'t use \"View Results Tree\" or \"View Results in Table\" listeners during th

相关标签:
1条回答
  • 2021-01-14 22:37

    I would say currently it is not possible with classic non-GUI mode of test execution, the options are in:

    1. Remove all the listeners from the test plan completely and control what is being stored in .jtl results file using Results File Configuration Properties
    2. Create a simple Java wrapper program to start a non-GUI JMeter test which will scan the Test Plan prior to starting and disable the listeners. It would be something like:

      StandardJMeterEngine jmeter = new StandardJMeterEngine();
      JMeterUtils.loadJMeterProperties("/path/to/your/jmeter.properties");
      JMeterUtils.setJMeterHome("/path/to/your/jmeter");
      JMeterUtils.initLocale();
      SaveService.loadProperties();
      HashTree testPlanTree = SaveService.loadTree(new File("/path/to/your/testplan"));
      SearchByClass<ResultCollector> listenersSearch = new SearchByClass<>(ResultCollector.class);
      testPlanTree.traverse(listenersSearch);
      Collection<ResultCollector> listeners = listenersSearch.getSearchResults();
      listeners.forEach(listener -> listener.setProperty(TestElement.ENABLED, false));
      jmeter.configure(testPlanTree);
      jmeter.run();
      
    3. Use Taurus tool to run your test, it has Modifications for Existing Scripts functionality so you will be able to disable listeners using simple declarative YAML syntax:

      ---
      execution:
        scenario:
          script: /path/to/your/testplan
          modifications:
            disable:  # Names of the tree elements to disable
            - View Results Tree
      
    0 讨论(0)
提交回复
热议问题