Sha256: 54fa6ffc3c4cc202c2894bd86a3708522eea37f4e414bb997b6e8f0be78a314a

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

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

  class RandomVariable
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "RandomVariable" : (params[:name] || "RandomVariable")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="#{testname}" enabled="true">
          <stringProp name="maximumValue"/>
          <stringProp name="minimumValue">1</stringProp>
          <stringProp name="outputFormat"/>
          <boolProp name="perThread">false</boolProp>
          <stringProp name="randomSeed"/>
          <stringProp name="variableName"/>
        </RandomVariableConfig>
      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/random_variable.rb