<?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 '2'>
<!ENTITY hellip   "&#x02026;" >
]>

<document prev="get-started.html" next="test_plan.html" id="$Id$">

<properties>
  <title>User's Manual: Building a Test Plan</title>
</properties>

<body>

<section name="&sect-num;. Building a Test Plan">
<p>A test plan describes a series of steps JMeter will execute when run.  A complete
test plan will consist of one or more Thread Groups, logic controllers, sample generating
controllers, listeners, timers, assertions, and configuration elements.
</p>

<subsection name="&sect-num;.1 Adding and Removing Elements" anchor="add_remove">
<p>Adding <a href="test_plan.html">elements to a test plan</a> can be done by right-clicking on an element in the
tree, and choosing a new element from the "<code>add</code>" list.  Alternatively, elements can
be loaded from file and added by choosing the "<code>merge</code>" or "<code>open</code>" option.</p>

<p>To remove an element, make sure the element is selected, right-click on the element,
and choose the "<code>remove</code>" option.</p>
</subsection>

<subsection name="&sect-num;.2 Loading and Saving Elements" anchor="load_save">
<p>To load an element from file, right click on the existing tree elements to which
you want to add the loaded element, and select the "<code>merge</code>" option.  Choose the file where
your elements are saved.  JMeter will merge the elements into the tree.</p>

<p>To save tree elements, right click on an element and choose the "<code>Save Selection As &hellip;</code>" option.
JMeter will save the element selected, plus all child elements beneath it.  In this way,
you can save test tree fragments and individual elements for later use.</p>

</subsection>

<subsection name="&sect-num;.3 Configuring Tree Elements" anchor="config_element">
<p>Any element in the test tree will present controls in JMeter's right-hand frame.  These
controls allow you to configure the behavior of that particular test element.  What can be
configured for an element depends on what type of element it is.</p>

<note>The Test Tree itself can be manipulated by dragging and dropping components around the test tree.</note>
</subsection>

<subsection name="&sect-num;.4 Saving the Test Plan" anchor="saving">
<p>Although it is not required, we recommend that you save the Test Plan to a
file before running it.  To save the Test Plan, select "<code>Save</code>" or "<code>Save Test Plan As &hellip;</code>" from the
File menu (with the latest release, it is no longer necessary to select the
Test Plan element first).</p>

<note>JMeter allows you to save the entire Test Plan tree or
only a portion of it.  To save only the elements located in a particular "branch"
of the Test Plan tree, select the Test Plan element in the tree from which to start
the "branch", and then click your right mouse button to access the "<code>Save Selection As &hellip;</code>" menu item.
Alternatively, select the appropriate Test Plan element  and then select "<code>Save Selection As &hellip;</code>" from
the Edit menu.
</note>
</subsection>

<subsection name="&sect-num;.5 Running a Test Plan" anchor="run">
<p>To run your test plan, choose "<code>Start</code>" (<keycombo><keysym>Control</keysym><keysym>r</keysym></keycombo>)
from the "<code>Run</code>" menu item.
When JMeter is running, it shows a small green box at the right hand end of the section just under the menu bar.
You can also check the "<code>Run</code>" menu.
If "<code>Start</code>" is disabled, and "<code>Stop</code>" is enabled,
then JMeter is running your test plan (or, at least, it thinks it is).</p>
<p>
The numbers to the left of the green box are the number of active threads / total number of threads.
These only apply to a locally run test; they do not include any threads started on remote systems when using client-server mode.
</p>
<note>Using GUI mode as described here should only be used when debugging your Test Plan. To run the real load test, use CLI mode.</note>
</subsection>

<subsection name="&sect-num;.6 Stopping a Test" anchor="stop">
<p>
There are two types of stop command available from the menu:
<ul>
<li><code>Stop</code> (<keycombo><keysym>Control</keysym><keysym>.</keysym></keycombo>) - stops the threads immediately if possible.
Many samplers are Interruptible which means that active samples can be terminated early.
The stop command will check that all threads have stopped within the default timeout, which is 5000 ms = 5 seconds.
[This can be changed using the JMeter property <code>jmeterengine.threadstop.wait</code>]
If the threads have not stopped, then a message is displayed.
The Stop command can be retried, but if it fails, then it is necessary to exit JMeter to clean up.
</li>
<li><code>Shutdown</code> (<keycombo><keysym>Control</keysym><keysym>,</keysym></keycombo>) - requests the
threads to stop at the end of any current work.
Will not interrupt any active samples.
The modal shutdown dialog box will remain active until all threads have stopped.</li>
</ul>
If Shutdown is taking too long. Close the Shutdown dialog box and select <code>Run</code>/<code>Stop</code>, or just press <keycombo><keysym>Control</keysym><keysym>.</keysym></keycombo>.
</p>
<p>
When running JMeter in CLI mode, there is no Menu, and JMeter does not react to keystrokes such as <keycombo><keysym>Control</keysym><keysym>.</keysym></keycombo>.
So JMeter CLI mode will listen for commands on a specific port (default <code>4445</code>, see the JMeter property <code>jmeterengine.nongui.port</code>).
JMeter supports automatic choice of an alternate port if the default port is being used
(for example by another JMeter instance). In this case, JMeter will try the next higher port, continuing until
it reaches the JMeter property <code>jmeterengine.nongui.maxport</code>) which defaults to <code>4455</code>.
If <code>maxport</code> is less than or equal to <code>port</code>, port scanning will not take place.
<br></br>
The chosen port is displayed in the console window.
<br/>
The commands currently supported are:
<ul>
<li><code>Shutdown</code> - graceful shutdown</li>
<li><code>StopTestNow</code> - immediate shutdown</li>
</ul>
These commands can be sent by using the <code>shutdown[.cmd|.sh]</code> or <code>stoptest[.cmd|.sh]</code> script
respectively. The scripts are to be found in the JMeter <code>bin</code> directory.
The commands will only be accepted if the script is run from the same host.
</p>
</subsection>

<subsection name="&sect-num;.7 Error reporting" anchor="error_reporting">
<p>
JMeter reports warnings and errors to the <code>jmeter.log</code> file, as well as some information on the test run itself.
JMeter shows the number of warnings/errors found in <code>jmeter.log</code> file next to the warning icon (triangle) at the right hand end of its window.
Click on the warning icon to show the <code>jmeter.log</code> file at the bottom of JMeter's window.
Just occasionally there may be some errors that JMeter is unable to trap and log; these will appear on the command console.
If a test is not behaving as you expect, please check the log file in case any errors have been reported (e.g. perhaps a syntax error in a function call).
</p>
<p>
Sampling errors (e.g. HTTP 404 - file not found) are not normally reported in the log file.
Instead these are stored as attributes of the sample result.
The status of a sample result can be seen in the various different Listeners.
</p>
</subsection>

</section>

</body>
</document>
