Sha256: 7653d38ff19d663edf4dc2f0dafc46f8a74d2b33ae1a90dacf4990f6d7040095

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module JmeterPerf
  class DSL
    # DSL method synonymous with the JMeter Element TestPlan
    # @see https://github.com/jlurena/jmeter_perf/wiki/1.-DSL-Documentation#testplan
    # @param [Hash] params Parameters for the TestPlan element (default: `{}`).
    # @yield block to attach to the TestPlan element
    # @return [JmeterPerf::TestPlan], a subclass of JmeterPerf::DSL that can be chained with other DSL methods.
    def test_plan(params = {}, &)
      node = JmeterPerf::TestPlan.new(params)
      attach_node(node, &)
    end
  end

  class TestPlan
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "TestPlan" : (params[:name] || "TestPlan")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="#{testname}" enabled="true">
          <stringProp name="TestPlan.comments"/>
          <boolProp name="TestPlan.functional_mode">false</boolProp>
          <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
          <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="#{testname}" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="TestPlan.user_define_classpath"/>
        </TestPlan>
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/dsl/test_plan.rb