Convert pdf tutorials to xml.
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1777783 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 349b6595a6
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE document[
|
||||
<!ENTITY sect-num '42'>
|
||||
<!ENTITY hellip "…" >
|
||||
]>
|
||||
|
||||
<document prev="best-practices.html" next="component_reference.html" id="$Id$">
|
||||
|
||||
<properties>
|
||||
<author email="dev@jmeter.apache.org">JMeter developers</author>
|
||||
<title>Include Controller Tutorial</title>
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
|
||||
<section name="§-num;. Include Controller Tutorial" anchor="include">
|
||||
<p>
|
||||
This is a short tutorial explaining the basics of the Include Controller. The Include Controller
|
||||
provides an easy way to include modules in a test plan. It is different than the Module Controller
|
||||
in a couple of ways.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>the Include Controller loads a simple controller with all it's samples, where as the Module
|
||||
Controller can use any controller</li>
|
||||
<li>the Include Controller doesn't use the workbench</li>
|
||||
<li>the Module Controller doesn't load from a file</li>
|
||||
<li>the Include Controller loads the module at runtime and doesn't display the contents of the
|
||||
Simple Controller</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
There are a couple of reasons why one might want to use the include controller.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Break a test plan into reusable modules</li>
|
||||
<li>Reduce the cost of maintaining test plans</li>
|
||||
<li>Reduce duplication of common process</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
For example, say you need to test an application that requires login. If each test plan had the login requests,
|
||||
a change in the login process would require updating all test plans. By making the login a module, all other
|
||||
test plans can reuse it. When the login process changes, the change is made to the module and all other test
|
||||
plans get the change. One limitation of the current implementation is the contents of the module are only
|
||||
loaded at runtime, so users can't view or edit the contents of an included module.
|
||||
</p>
|
||||
|
||||
<figure width="417" height="130" image="includecontroller.png">Include Controller</figure>
|
||||
|
||||
<p>
|
||||
The Include Controller has two properties. The <code>name</code> and the <code>filename</code>. The <code>name</code>
|
||||
is the descriptive name for the controller in the test plan. The <code>filename</code> is the name of the <code>.jmx</code> file.
|
||||
</p>
|
||||
|
||||
<subsection name="§-num;.1 Step-by-step" anchor="step-by-step">
|
||||
|
||||
<ol>
|
||||
<li>Start JMeter</li>
|
||||
<li>Select the workbench</li>
|
||||
<li><menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Logic Controller</guimenuitem>
|
||||
<guimenuitem>Simple Controller</guimenuitem>
|
||||
</menuchoice>
|
||||
</li>
|
||||
<li>Enter <code>module1</code> in the name</li>
|
||||
<li>Now add one or more samples to the controller</li>
|
||||
<li>Once the samples are added, right click on <code>module1</code></li>
|
||||
<li>Select <code>save as</code> and save it as <code>module1.jmx</code></li>
|
||||
</ol>
|
||||
|
||||
</subsection>
|
||||
|
||||
<p>
|
||||
<code>module1.jmx</code> can now be used with any test plan. The Include Controller hasn't been tested
|
||||
with other controllers as the root element. If you need to use other controllers, use a Simple Controller
|
||||
as the root and add other controllers to it.
|
||||
</p>
|
||||
|
||||
</section>
|
||||
|
||||
</body>
|
||||
|
||||
</document>
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE document[
|
||||
<!ENTITY sect-num '42'>
|
||||
<!ENTITY hellip "…" >
|
||||
]>
|
||||
|
||||
<document next="junitsampler_tutorial.html" id="$Id$">
|
||||
|
||||
<properties>
|
||||
<author email="dev@jmeter.apache.org">JMeter developers</author>
|
||||
<title>Apache JMeter HTTP(S) Test Script Recorder</title>
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
|
||||
<section name="§-num;. Apache JMeter HTTP(S) Test Script Recorder" anchor="script-recorder">
|
||||
|
||||
<p>
|
||||
This tutorial attempts to explain the exact steps for recording HTTP/HTTPS. For those new to JMeter, one easy way to create a test plan is to use the Recorder.
|
||||
</p>
|
||||
|
||||
<subsection name="§-num;.1 JMeter configuration" anchor="configuration">
|
||||
|
||||
<p>
|
||||
Since JMeter 2.10, recording has been improved to better handle embedded resources and creation of certificates on the fly.
|
||||
To enable these features, JMeter uses <code>keytool</code> utility (available in JRE/JDK) so you need to ensure your
|
||||
configuration is correct, read <a href="https://wiki.apache.org/jmeter/TestRecording210">this wiki page before starting.</a>
|
||||
</p>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.2 Basic Instructions" anchor="basic-instructions">
|
||||
|
||||
<ol>
|
||||
<li>Go to <code>JMETER_HOME/bin</code> and start JMeter with <code>jmeterw.cmd</code> on Windows
|
||||
and <code>jmeter</code> on Linux/Unix</li>
|
||||
<li>Select <code>Test Plan</code> on the tree</li>
|
||||
<li>Right click on the <code>Test Plan</code> and add a new thread group:
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Threads (Users)</guimenuitem>
|
||||
<guimenuitem>Thread Group</guimenuitem>
|
||||
</menuchoice>
|
||||
<figure width="676" height="233" image="add-threadgroup.png">Add Thread Group</figure>
|
||||
</li>
|
||||
<li>Select the Thread Group</li>
|
||||
<li>Right click
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Config Element</guimenuitem>
|
||||
<guimenuitem>HTTP Request Defaults</guimenuitem>
|
||||
</menuchoice>
|
||||
<figure width="810" height="340" image="add-request-defaults.png">Add HTTP Request Defaults</figure>
|
||||
</li>
|
||||
<li>In new HTTP Request Defaults element:
|
||||
<dl>
|
||||
<dt><code>Server name</code></dt><dd>enter <code>example.com</code></dd>
|
||||
<dt><code>Path</code></dt><dd>leave blank</dd>
|
||||
</dl>
|
||||
<figure width="879" height="469" image="http-config/http-request-defaults.png">HTTP Request Defaults dialog</figure>
|
||||
</li>
|
||||
<li>Right click on the <code>Thread Group</code> and add a recording controller:
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Logic Controller</guimenuitem>
|
||||
<guimenuitem>Recording Controller</guimenuitem>
|
||||
</menuchoice>
|
||||
<figure width="766" height="332" image="add-recording-controller.png">Add Recording Controller</figure>
|
||||
</li>
|
||||
<li>Next, select <code>WorkBench</code></li>
|
||||
<li>Right click on <code>WorkBench</code> and add the recorder:
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Non-Test Elements</guimenuitem>
|
||||
<guimenuitem>HTTP(S) Test Script Recorder</guimenuitem>
|
||||
</menuchoice>
|
||||
<figure width="738" height="222" image="add-script-recorder.png">Add HTTP(S) Test Script Recorder</figure>
|
||||
</li>
|
||||
<li>On <code>HTTP(S) Test Script Recorder</code>, click the <code>Add</code> button in <code>URL Patterns to Include</code>.
|
||||
This will create a blank entry; enter <code>.*\.html</code>.
|
||||
<figure width="703" height="271" image="specify-url-pattern.png">Add URL pattern</figure>
|
||||
</li>
|
||||
<li>Right click on <code>HTTP(S) Test Script Recorder</code> and add a listener:
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Listener</guimenuitem>
|
||||
<guimenuitem>View Results Tree</guimenuitem>
|
||||
</menuchoice>
|
||||
<figure width="782" height="605" image="add-results-tree.png">Add a View Results Tree</figure>
|
||||
</li>
|
||||
<li>Return to <code>HTTP(S) Test Script Recorder</code>, and click the <code>Start</code> button at the bottom.</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
This will start the JMeter proxy server which is used to intercept the browser requests.
|
||||
A file called <code>ApacheJMeterTemporaryRootCA.crt</code> will be generated in <code>jmeter/bin</code>
|
||||
folder. Install this certificate in your browser, if you don't know how to do it,
|
||||
read <a href="component_reference.html#HTTP%28S%29_Test_Script_Recorder">Installing the JMeter CA certificate for HTTPS recording</a>
|
||||
</p>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.3 Configure your browser to use the JMeter Proxy" anchor="configue-browser">
|
||||
|
||||
<p>
|
||||
At this point, JMeter's proxy is running. For this exercise, we will use Iceweasel/Firefox
|
||||
to view some pages on the JMeter website.
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
<li>Start Iceweasel/Firefox, but do not close JMeter.</li>
|
||||
<li>From the tool bar, click
|
||||
<menuchoice>
|
||||
<guimenuitem>Edit</guimenuitem>
|
||||
<guimenuitem>Preferences</guimenuitem>
|
||||
</menuchoice> (or
|
||||
<menuchoice>
|
||||
<guimenuitem>Tools</guimenuitem>
|
||||
<guimenuitem>Preferences</guimenuitem>
|
||||
</menuchoice> or type <code>about:preferences#advanced</code>
|
||||
as URL). This should bring up the options.
|
||||
<figure width="914" height="566" image="firefox-network-settings.png">Firefox Advanced Settings</figure>
|
||||
</li>
|
||||
<li>Select the <code>Advanced</code> tab, and <code>Network</code> tab</li>
|
||||
<li>Click <code>Settings</code> button near the top.</li>
|
||||
<li>On the new pop-up, check <code>Manual proxy configuration</code>. The address and
|
||||
port fields should be enabled now.
|
||||
<dl>
|
||||
<dt><code>Address</code></dt><dd>enter <code>localhost</code> or the IP address of your system</dd>
|
||||
<dt><code>Port</code></dt><dd>enter <code>8888</code>.</dd>
|
||||
</dl>
|
||||
<figure width="532" height="240" image="firefox-configure-proxy.png">Firefox Proxy Settings</figure>
|
||||
</li>
|
||||
<li>Check <code>Use this proxy server for all protocols</code></li>
|
||||
<li>Click <code>OK</code> button. This should return you to the browser</li>
|
||||
</ol>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.4 Record your navigation" anchor="navigation-recording">
|
||||
|
||||
<ol>
|
||||
<li>With your browser, in the <code>Address</code> bar at the top, enter <code>http://example.com/index.html</code> (replace <code>example.com</code> with your websites address).
|
||||
and hit the <code>enter</code> key.</li>
|
||||
<li>Click on a few links on your sites pages.</li>
|
||||
<li>Close your browser and bring up the JMeter window.</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
Expand the Thread Group and there should be several samplers. At this point, the test plan can
|
||||
be saved as is.
|
||||
<note>If you forget to add default HTTP Request settings, you will have to manually
|
||||
delete the server name, and port.</note>
|
||||
</p>
|
||||
|
||||
<figure width="258" height="194" image="example-recording.png">Recording Example</figure>
|
||||
<p>
|
||||
In this sample, there aren't any default request parameters. If a particular request parameter
|
||||
is required by all pages, the request defaults is where one would add the entries.
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
<li>Select <code>Thread Group</code></li>
|
||||
<li>Right click
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Listener</guimenuitem>
|
||||
<guimenuitem>Summary Report</guimenuitem>
|
||||
</menuchoice> to add an summary listener.
|
||||
<figure width="775" height="446" image="add-summary-report.png">Add Summary Report</figure>
|
||||
</li>
|
||||
<li>The Summary Listener will show some basic statistics.</li>
|
||||
<li>Select <code>Thread Group</code> and change a few defaults:
|
||||
<dl>
|
||||
<dt><code>Number of Threads</code></dt><dd>enter <code>5</code></dd>
|
||||
<dt><code>Ramp-Up Period</code></dt><dd>do not change</dd>
|
||||
<dt><code>Loop Count</code></dt><dd>enter <code>100</code></dd>
|
||||
</dl>
|
||||
<figure width="357" height="288" image="example-thread-group.png">Configure Thread Group</figure>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.5 Start the test" anchor="test-start">
|
||||
|
||||
<p>
|
||||
At this point, we are ready to run our test plan and see what happens. Save the test plan. When you're
|
||||
ready to run the test, there are two ways:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Either use the menu and select
|
||||
<menuchoice>
|
||||
<guimenuitem>Run</guimenuitem>
|
||||
<guimenuitem>Start</guimenuitem>
|
||||
</menuchoice>
|
||||
or use the keyboard and press <keycombo><keysym>Ctrl</keysym><keysym>R</keysym></keycombo>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Before you start the test, select <code>Summary Report</code>. As the test runs, the statistics will change
|
||||
until the test is done. At the end of the test, the summary report should look like this.
|
||||
<figure width="984" height="220" image="example-summary-report.png">Example Summary Report</figure>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
While the test is running, in the upper right-hand corner, there should be a green circle. When the test is done, the circle should be grey.
|
||||
<figure width="132" height="39" image="example-running.png">Example Running</figure>
|
||||
</p>
|
||||
|
||||
</subsection>
|
||||
|
||||
</section>
|
||||
|
||||
</body>
|
||||
|
||||
</document>
|
||||
|
|
@ -0,0 +1,239 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE document[
|
||||
<!ENTITY sect-num '42'>
|
||||
<!ENTITY hellip "…" >
|
||||
]>
|
||||
|
||||
<document prev="jmeter_proxy_step_by_step.html" id="$Id$">
|
||||
|
||||
<properties>
|
||||
<author email="dev@jmeter.apache.org">JMeter developers</author>
|
||||
<title>JUnit Sampler Tutorial</title>
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
|
||||
<section name="§-num;. JUnit Sampler Tutorial" anchor="junit">
|
||||
|
||||
<p>
|
||||
This tutorial attempts to explain the basic design, functionality and usage of the new JUnit Sampler for JMeter.
|
||||
The sampler was introduced in version 2.1.2 release of JMeter. Earlier releases do not have the sampler.
|
||||
</p>
|
||||
|
||||
<subsection name="§-num;.1 Design" anchor="design">
|
||||
|
||||
<p>
|
||||
The current implementation supports standard JUnit convention and extensions, like <code>oneTimeSetUp</code>
|
||||
and <code>oneTimeTearDown</code>. Other features can be added on request. The sampler works like the JavaSampler
|
||||
with some differences.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Rather than use JMeter's test interface, it scans the jar files for classes extending JUnit's
|
||||
<code>TestCase</code> class. This means any class or subclass.</li>
|
||||
<li>JUnit test jar files are copied to <code>jmeter/lib/junit</code> instead of
|
||||
<code>jmeter/lib</code></li>
|
||||
<li>JUnit sampler does not use name/value pairs for configuration. The sampler assumes
|
||||
<code>setUp</code> and <code>tearDown</code> will configure the test correctly.
|
||||
<note>Note: <code>setUp</code> and <code>tearDown</code> methods must be declared <code>public</code>,
|
||||
so that JMeter can use it.</note>
|
||||
</li>
|
||||
<li>The sampler measures the elapsed time only for the test method and does not include
|
||||
<code>setUp</code> and <code>tearDown</code>.
|
||||
</li>
|
||||
<li>Each time the test method is called, JMeter will pass the result to the listeners.</li>
|
||||
<li>Support for <code>oneTimeSetUp</code> and <code>oneTimeTearDown</code> is done as a method.
|
||||
Since JMeter is multi-threaded, we cannot call <code>oneTimeSetUp</code>/<code>oneTimeTearDown</code>
|
||||
the same way maven does it.</li>
|
||||
<li>The sampler reports unexpected exceptions as errors.</li>
|
||||
</ul>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.2 Functionality" anchor="functionality">
|
||||
|
||||
<p>
|
||||
Here is a description of the functionality.
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>Name</dt><dd>name for the sample. This is the same as all JMeter samplers.</dd>
|
||||
<dt>Package Filter</dt><dd>provides a way to filter the classes by package name.</dd>
|
||||
<dt>Classname</dt><dd>the name of the class to test. The sampler will scan the jar files in
|
||||
<code>jmeter/lib/ext</code> and <code>jmeter/lib/junit</code> for classes extending
|
||||
JUnit's <code>TestCase</code>.</dd>
|
||||
<dt>Constructor String</dt><dd>a string to pass to the string constructor of the test class.</dd>
|
||||
<dt>Test Method</dt><dd>the name of the method to test in the sampler.</dd>
|
||||
<dt>Success message</dt><dd>a descriptive message indicating what success means.</dd>
|
||||
<dt>Success code</dt><dd>an unique code indicating the test was successful.</dd>
|
||||
<dt>Failure message</dt><dd>a descriptive message indicating what failure means.</dd>
|
||||
<dt>Failure code</dt><dd>an unique code indicating the test failed</dd>
|
||||
<dt>Error message</dt><dd>a description for errors</dd>
|
||||
<dt>Error code</dt><dd>some code for errors. Does not need to be unique</dd>
|
||||
<dt>Do not call <code>setUp</code> and <code>tearDown</code></dt><dd>set the sampler not
|
||||
to call <code>setUp</code> and <code>tearDown</code>. By default, <code>setUp</code> and
|
||||
<code>tearDown</code> should be called. Not calling those methods could affect the test and
|
||||
make it inaccurate. This option should be used with caution.
|
||||
<note>If the selected method is <code>oneTimeSetUp</code> or <code>oneTimeTearDown</code>,
|
||||
this option should be checked.</note></dd>
|
||||
<dt>Append assertion error</dt><dd>By default, the sampler will not append the assert failures
|
||||
to the failure message. To see the message in the result tree, check the option.</dd>
|
||||
<dt>Append runtime exception</dt><dd>By default, the sampler will not append the exceptions
|
||||
to the failure message. To see the stacktrace, check the option</dd>
|
||||
</dl>
|
||||
|
||||
<figure width="397" height="536" image="junit_sampler.png">JUnit Request</figure>
|
||||
|
||||
<p>
|
||||
The current implementation of the sampler will try to create an instance using the string constructor
|
||||
first. If the test class does not declare a string constructor, the sampler will look for an empty
|
||||
constructor. Example below:
|
||||
</p>
|
||||
|
||||
<example title="Constructor Examples" anchor="constructor-examples">
|
||||
Empty Constructor:
|
||||
<source>
|
||||
public class myTestCase {
|
||||
public myTestCase() {}
|
||||
}
|
||||
</source>
|
||||
|
||||
String Constructor:
|
||||
<source>
|
||||
public class myTestCase {
|
||||
public myTestCase(String text) {
|
||||
super(text);
|
||||
}
|
||||
}
|
||||
</source>
|
||||
</example>
|
||||
|
||||
<p>
|
||||
By default, JMeter will provide some default values for the success/failure code and message.
|
||||
Users should define a set of unique success and failure codes and use them uniformly across all tests.
|
||||
</p>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.3 Usage" anchor="usage">
|
||||
|
||||
<p>
|
||||
Here is a short step-by-step.
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
<li>Write your JUnit test and jar the classes</li>
|
||||
<li>Copy and paste the jar files into <code>jmeter/lib/junit</code> directory</li>
|
||||
<li>Start JMeter</li>
|
||||
<li>Select <code>Test Plan</code></li>
|
||||
<li>Right click
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Thread Group</guimenuitem>
|
||||
</menuchoice></li>
|
||||
<li>Select <code>Thread Group</code></li>
|
||||
<li>Right click
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Sampler</guimenuitem>
|
||||
<guimenuitem>JUnit Request</guimenuitem>
|
||||
</menuchoice></li>
|
||||
<li>Enter <code>my unit test</code> in the name</li>
|
||||
<li>Enter the package of your JUnit test</li>
|
||||
<li>Select the class you want to test</li>
|
||||
<li>Select a method to test</li>
|
||||
<li>Enter <code>test successful</code> in success message</li>
|
||||
<li>Enter <code>1000</code> in success code</li>
|
||||
<li>Enter <code>test failed</code> in failure message</li>
|
||||
<li>Enter <code>0001</code> in failure code</li>
|
||||
<li>Select the Thread Group</li>
|
||||
<li>Right click
|
||||
<menuchoice>
|
||||
<guimenuitem>Add</guimenuitem>
|
||||
<guimenuitem>Listener</guimenuitem>
|
||||
<guimenuitem>View Results Tree</guimenuitem>
|
||||
</menuchoice></li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
One benefit of the JUnit sampler is it allows the user to select any method from a variety
|
||||
of unit tests to create a test plan. This should reduce the amount of code an user needs to
|
||||
write to create a variety of test scenarios. From a basic set of test methods, different
|
||||
sequences and tests can be created using JMeter's GUI.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Test Plan1
|
||||
<source>
|
||||
TestCase1.testImportCustomer
|
||||
TestCase2.testUpdateRandomCustomer
|
||||
TestCase1.testSelect100
|
||||
TestCase2.testUpdateOrder
|
||||
TestCase1.testSelect1000
|
||||
</source>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
TestPlan2
|
||||
<source>
|
||||
TestCase1.testImportCustomer
|
||||
TestCase1.testSelect100
|
||||
TestCase1.testSelect1000
|
||||
TestCase2.testAdd100Customers
|
||||
</source>
|
||||
</p>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.4 General Guidelines" anchor="guidelines">
|
||||
|
||||
<p>
|
||||
Here are some general guidelines for writing JUnit tests so they work well with JMeter. Since JMeter
|
||||
runs multi-threaded, it is important to keep certain things in mind.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Write the <code>setUp</code> and <code>tearDown</code> methods so they are thread safe. This
|
||||
generally means avoid using static members.</li>
|
||||
<li>Make the test methods discrete units of work and not long sequences of actions. By keeping
|
||||
the test method to a discrete operation, it makes it easier to combine test methods to create
|
||||
new test plans.</li>
|
||||
<li>Avoid making test methods depend on each other. Since JMeter allows arbitrary sequencing of
|
||||
test methods, the runtime behavior is different than the default JUnit behavior.</li>
|
||||
<li>If a test method is configurable, be careful about where the properties are stored. Reading
|
||||
the properties from the Jar file is recommended.</li>
|
||||
<li>Each sampler creates an instance of the test class, so write your test so the setup happens
|
||||
in <code>oneTimeSetUp</code> and <code>oneTimeTearDown</code>.</li>
|
||||
<li>If you select a class and no methods show up, it means the sampler had a problem creating an
|
||||
instance of the test class. The best way to debug this is to add some <code>System.out</code>
|
||||
to your class constructor and see what is happening.</li>
|
||||
</ul>
|
||||
|
||||
</subsection>
|
||||
|
||||
</section>
|
||||
|
||||
</body>
|
||||
|
||||
</document>
|
||||