<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Running+the+Asterisk+Test+Suite">Running the Asterisk Test Suite</a></h2>
<h4>Page <b>added</b> by <a href="https://wiki.asterisk.org/wiki/display/~mjordan">Matt Jordan</a>
</h4>
<br/>
<div class="notificationGreySide">
<p>There are a number of ways the Asterisk Test Suite can be executed:</p>
<ul>
        <li>Execute all tests</li>
        <li>Execute a single test</li>
        <li>Execute a set of tests that share common tags</li>
        <li>Execute a pre-defined set of tests</li>
</ul>
<h2><a name="RunningtheAsteriskTestSuite-Executingalltests"></a>Executing all tests</h2>
<p>The simplest way of executing tests, all tests in the Test Suite can be run by running the runtests.py script.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># ./runtests.py
Running tests for Asterisk SVN-trunk-r366462M
...
--> Running test 'tests/example' ...
Making sure Asterisk isn't running ...
Running ['tests/example/run-test'] ...</pre>
</div></div>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Depending on permissions and the modules installed, you may need to run the runtests.py script with elevated permissions.</td></tr></table></div>
<p>Since this can take a long time to execute to completion - and may cover functionality you do not want to test - there are a variety of other ways to run tests as well.</p>
<h2><a name="RunningtheAsteriskTestSuite-Executingasingletest"></a>Executing a single test</h2>
<p>A single test can be executed using the <em>-t</em> command line option.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># ./runtests.py -t tests/dialplan</pre>
</div></div>
<h2><a name="RunningtheAsteriskTestSuite-Executingasetoftestsbytag"></a>Executing a set of tests by tag</h2>
<p>Many tests in the Asterisk Test Suite have tags that group them according to functionality that they test. The tags currently in use by all executable tests in the Test Suite can be determined using the <em>-L</em> command line option:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># ./runtests.py -L
Available test tags:
        AGI AMI apps
        bridge ccss CDR
        chan_local chanspy confbridge
        connected_line dial dialplan
        dialplan_lua directory DTMF
        fax fax_gateway fax_passthrough
        features gosub GoSub
        IAX incomplete macro
        mixmonitor page parking
        pickup queues redirecting
        SIP subroutine transfer
voicemail</pre>
</div></div>
<p>All tests that have a tag can be executed using the <em>-g</em> command line option:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># ./runtests.py -g SIP</pre>
</div></div>
<p>Multiple tags can be specified as well, using multiple invocations of the <em>-g</em> command line option. A test must satisfy each tag specified in order to be executed.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># ./runtests.py -g SIP -g CDR</pre>
</div></div>
<h2><a name="RunningtheAsteriskTestSuite-Executingpredefinedsetsoftests"></a>Executing pre-defined sets of tests</h2>
<p>Pre-defined sets of tests can be set up in the top level <em>test-config.yaml</em> configuration file. When the runtests.py script starts, it looks for the key in <em>global-settings/test-configuration</em>. The value specified for that key is used to look up test run specific settings. An example is shown below, where the <em>test-configuration</em> is set to <em>config-quick</em>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># Global settings
global-settings:
# The active test configuration. The value must match a subsequent key
# in this file, which defines the global settings to apply to the test execution
# run.
test-configuration: config-quick
config-quick:</pre>
</div></div>
<p>A test configuration can exclude tests from a run by using the <em>exclude-tests</em> key. Each value under that key is a test that will <b>not</b> be run when the <em>runtests.py</em> script executes.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"># Exclude some long-running tests
config-quick:
exclude-tests:
- 'authenticate_invalid_password'
- 'check_voicemail_callback'
- 'check_voicemail_delete'
- 'check_voicemail_dialout'
- 'check_voicemail_envelope'
- 'check_voicemail_new_user'
- 'check_voicemail_nominal'
- 'check_voicemail_reply'
- 'leave_voicemail_external_notification'
- 'leave_voicemail_nominal'
- 'gateway_g711_t38'
- 'gateway_mix1'
- 'gateway_mix2'
- 'gateway_mix3'
- 'gateway_mix4'
- 'gateway_native_t38'
- 'gateway_native_t38_ced'
- 'gateway_no_t38'
- 'gateway_t38_g711'
- 'gateway_timeout1'
- 'gateway_timeout2'
- 'gateway_timeout3'
- 'gateway_timeout4'
- 'gateway_timeout5'</pre>
</div></div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Running+the+Asterisk+Test+Suite">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Running+the+Asterisk+Test+Suite?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>