-
Notifications
You must be signed in to change notification settings - Fork 0
3. Generating DSL Methods
Jean Luis Urena edited this page Oct 28, 2024
·
2 revisions
If you need additional JMeter Elements not already included in the gem, you can generate them with the included rake task.
# Rakefile
require 'jmeter_perf'
spec = Gem::Specification.find_by_name 'jmeter_perf'
rakefile = "#{spec.gem_dir}/lib/my_gem/Rakefile"
load rakefile
<!--idl.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<hashTree>
<!--NOTE the "testname" will be used-->
<CounterConfig guiclass="CounterConfigGui" testclass="CounterConfig" testname="Counter" enabled="true">
<stringProp name="CounterConfig.start"></stringProp>
<stringProp name="CounterConfig.end"></stringProp>
<stringProp name="CounterConfig.incr"></stringProp>
<stringProp name="CounterConfig.name"></stringProp>
<stringProp name="CounterConfig.format"></stringProp>
<boolProp name="CounterConfig.per_user">true</boolProp>
<boolProp name="CounterConfig.reset_on_tg_iteration">true</boolProp>
</CounterConfig>
</hashTree>
</hashTree>
</jmeterTestPlan>
$ bundle exec rake jmeter_perf:dsl_generate["path/to/dsl/directory/","path/to/idl.xml"]
This will generate files pertaining to your JMeter Element. You can then use the standard DSL to run them.
Example:
# Some test
JmeterPerf.test do
counter name: 'My Counter', start: 1, end: 10, increment: 1, per_user: true do
http_sampler name: 'Counter Request', url: 'http://example.com/counter'
end
end