blob: ddb165c5bb0383ca2ef1e30c8724fdb466162ce8 [file] [log] [blame]
<!DOCTYPE html>
<head>
<title>RCPTT Documentation Center</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/bootstrap.min.css">
<link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/main.css">
<link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/prism.css">
<link rel="icon" href="https://www.eclipse.org/rcptt/shared/img/favicon.ico">
<script src="https://www.eclipse.org/rcptt/shared/js/jquery.min.js"></script>
<script src="https://www.eclipse.org/rcptt/shared/js/bootstrap.min.js"></script>
<script src="https://www.eclipse.org/rcptt/shared/js/prism.js"></script>
<script src="https://www.eclipse.org/rcptt/shared/js/ecl.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-39589807-5', 'eclipse.org');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="before-footer">
<header>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">RCPTT Documentation Center</span>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active" >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/getstarted">User Guide</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/faq/">FAQ</a>
</li>
<li>
<a href="http://eclipse.org/rcptt">Back to RCPTT Main Site</a>
</li>
<li>
<a href="http://eclipse.org">Eclipse.org</a>
</li>
</ul>
</div>
</nav>
</header>
<section class="content">
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="rcptt-sidebar">
<ul class="nav">
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/getstarted/">Get Started</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/testeditor/">Test Case Editor</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/controlpanel">Control Panel</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/assertions/">Assertions</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/">Eclipse Command Language</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/new-command-guide/">New ECL Command Guide</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/excel-import-export/">ECL commands for Excel import and export</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/xml-import-export/">ECL commands for XML import and export</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/">Contexts</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/workspace/">Workspace</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/workbench/">Workbench</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/launch/">Launch</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/preferences/">Preferences</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/parameters/">Parameters</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/group/">Group</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/folder/">Folder</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/default/">Default</a>
</li>
<li class="active" >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/super/">Super</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/ecl/">ECL Script</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/">Verifications</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/text/">Text</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/treetable/">Table/Tree</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/errorlog/">Error Log</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/time/">Time</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/procedures/">Procedures and Variables</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/">Test Runner</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/arguments/">Arguments</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/maven/">Maven plugin</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/">RAP</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/install/">Install instructions</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/recordReplay/">Record and Replay</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/capability/">Capability Contexts</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/rap-commands/">ECL commands</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/rap-maven/">Maven plugin</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/integration/">Integration</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/integration/test-rail-integration/">TestRail</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/integration/zephyr-integration/">Zephyr</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-sm-9">
<h1>Super Contexts</h1>
<p></p>
<h3>Introduction</h3>
<p>A test case in RCPTT consists of two parts:</p>
<ul>
<li>list of contexts, defining an application state</li>
<li>ECL script describing UI actions and validating that application behavior in given state is correct.</li>
</ul>
<p>In some cases it might be required to execute same actions with just a few variances in initial state or arguments
of script commands. Common examples are:</p>
<ul>
<li>Test case verifies that a project can be built. An executed action is just a verification that Problems view is empty,
but this should be done for several different projects. We can say that we have the same behavior for different states of workspace.</li>
<li>Test case verifies some form (like a validation of new Java Class dialog). We execute basically the same actions
(type values in fields and check error message), but with different command arguments.</li>
</ul>
<p>So we have added supercontexts which can be used to cover both of scenarios above. A supercontext is a list of contexts
of the same type, which can be refered in test cases just as usual contexts, but during an execution, a test case will
be executed several times with each of these contexts. In this blog post we are going to describe how to create test cases
for two examples mentioned above.</p>
<h3>First example - building Java projects</h3>
<p>We are going to create a test case which verifies that Problems view contains no errors for the following states of a workspace:</p>
<ul>
<li>empty workspace</li>
<li>empty Java project</li>
<li>"Hello, World!" Java project</li>
<li>two referencing Java projects</li>
</ul>
<p>We start with a creation of a usual test case which verifies that Problems view contains no errors.</p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-1.png"></img>
</div>
<p>Next, we create three more workspace contexts:</p>
<ul>
<li>Empty Java Project</li>
<li>HelloWorld java Project</li>
<li>Two Java Projects</li>
</ul>
<p>Then we create a new workspace supercontext (by selecting New -> Super Context) in a context menu in Test Explorer and add all
our four workspace contexts into it:</p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-editor-2.png"></img>
</div>
<p>Now we can get back to originally created test case and replace Emtpy Workspace context with Workspaces supercontext.
If we execute this test case, an Execution view shows it has been executed four times, each time with different workspace context:</p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-3.png"></img>
</div>
<h3>Second example - validating New Java Project dialog</h3>
<p>For the next test case we are going to reuse Java Perspective workbench context and HelloWorld Java Project workspace context.</p>
<p>We record a filling values in New Java project and validating an error message:</p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-script-example.png"></img>
</div>
<p><br>
Now we need to parameterize it - at first we create Parameters context "Valid Input" with parameters we are going to change:</p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-4.png"></img>
</div>
<p>At second we replace string values in script with <b>$paramName</b> and adding parameters context to a test case:</p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-5.png"></img>
</div>
<p>And the rest is straightforward - create parameters context for each set of input values, put them into parameters supercontext and put this supercontext into testcase.</p>
<p>Once test case is executed, we can see that all inputs were iterated:
<br></p>
<div class="screenshot">
<img src="https://www.eclipse.org/rcptt/shared/img/screenshot-super-context-6.png"></img>
</div>
<h3>More about supercontexts</h3>
<p>If a test case refers to more that one supercontext, then all possible combinations of tuples from these supercontexts
will be used. For instance, for our example above if we would like to check that all these Java projects can be built both
with Java 1.6 and Java 1.5 compiler settings, we could create Preferences supercontext with two contexts <b>1.6</b> and <b>1.5</b>, add
it to a test case, so that it will be executed 8 times and Execution view would show a list like this:</p>
<ul>
<li>No Build Errors (Empty Workspace, 1.5)</li>
<li>No Build Errors (Empty Workspace, 1.6)</li>
<li>No Build Errors (Empty Java Project, 1.5)</li>
<li>No Build Errors (Empty Java Project, 1.6)</li>
<li>No Build Errors (HelloWorld Java Project, 1.5)</li>
<li>No Build Errors (HelloWorld Java Project, 1.6)</li>
<li>No Build Errors (Two Java Projects, 1.5)</li>
<li>No Build Errors (Two Java Projects, 1.6)</li>
</ul>
<p>In case we need to iterate over context pairs without this 'cartesian product'
(like, workspace context and parameters context specific for this workspace), this can be done by
creating a single group supercontext, referencing to several group contexts. For instance, if we create a test case
which validates a build error count, then we can have a structure like this:</p>
<ul>
<li>build errors (group supercontext)</li>
<ul><li>one build error (group context)</li>
<ul><li>workspace1 (workspace context)</li>
<li>params1 (params context)</li></ul>
<li>two build errors (group context)</li>
<ul><li>workspace2 (workspace context)</li>
<li>params2 (params context)</li>
</ul>
</ul>
</ul>
<h3>Conclusion</h3>
<p>Supercontexts are powerful but might be hard for inexperienced users. In case when there are only a few variances of a test case which are
unlikely to be changed, it might be much more easier and faster to create few separate test cases instead of dealing with parameterization.</p>
</div>
</div>
</div>
</section>
<script src="https://www.eclipse.org/rcptt/shared/js/main.js"></script>
</body>