Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Dashboard
Cargo
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h2>Functional Testing with Cargo</h2><table class="wysiwyg-macro" data-macro-name="excerpt" data-macro-parameters="atlassian-macro-output-type=BLOCK" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2V4Y2VycHQ6YXRsYXNzaWFuLW1hY3JvLW91dHB1dC10eXBlPUJMT0NLfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>This page explains how to do functional testing with the Cargo Java API and JUnit.</p></td></tr></table><table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="title=Are you using ANT or Maven2/Maven3?" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86dGl0bGU9QXJlIHlvdSB1c2luZyBBTlQgb3IgTWF2ZW4yL01hdmVuMz99&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>If you are relying on ANT or Maven2/Maven3 for your build, it is probably easier for you to use the associated tasks/plugin directly:</p><ul><li>The documentation for the CARGO ANT tasks can be found here: <a class="confluence-link" href="/display/CARGO/Ant+support" data-linked-resource-id="13120" data-linked-resource-type="page" data-linked-resource-default-alias="Ant support" data-base-url="http://docs.codehaus.org">Ant support</a>.</li><li>The documentation for the CARGO Maven2/Maven3 plugin can be found here: <a class="confluence-link" href="/display/CARGO/Maven2+plugin" data-linked-resource-id="34460" data-linked-resource-type="page" data-linked-resource-default-alias="Maven2 plugin" data-base-url="http://docs.codehaus.org">Maven2 plugin</a>.</li></ul><p>Note that the Maven2/Maven3 plugin also has <a class="confluence-link" href="/display/CARGO/Maven2+Archetypes" data-linked-resource-id="74316" data-linked-resource-type="page" data-linked-resource-default-alias="Maven2 Archetypes" data-base-url="http://docs.codehaus.org">archetypes</a> you can directly use as a skeleton for integration.</p></td></tr></table><p> </p><h3>Example</h3><p>The best is to create a JUnit <code>TestSetup</code> extension so that you start and stop your container once for the whole test suite. For example:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>import junit.extensions.TestSetup; import junit.framework.Test; [...] public class CargoTestSetup extends TestSetup { InstalledLocalContainer container; public CargoTestSetup(Test test) { super(test); } protected void setUp() throws Exception { // (1) Optional step to install the container from a URL pointing to its distribution Installer installer = new ZipURLInstaller( new URL("http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip")); installer.install(); // (2) Create the Cargo Container instance wrapping our physical container LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration( "tomcat6x", ContainerType.INSTALLED, ConfigurationType.STANDALONE); InstalledLocalContainer container = (InstalledLocalContainer) new DefaultContainerFactory().createContainer( "tomcat6x", ContainerType.INSTALLED, configuration); container.setHome(installer.getHome()); // (3) Statically deploy some WAR (optional) configuration.addDeployable(new WAR("cargo.war")); // (4) Start the container container.start(); } protected void tearDown() throws Exception { // (6) Stop the container container.stop(); } } </pre></td></tr></table><p>Then write your test case. For example:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>import junit.framework.TestCase; import junit.framework.Test; import junit.framework.TestSuite; [...] public class MyTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(MyTest.class); return new CargoTestSetup(suite); } public void testSomething() { // (5) Perform any test you wish here [...] } } </pre></td></tr></table><h3>References</h3><ul><li><a class="confluence-link unresolved" data-filename="Vincent Massol Think Tank - Using Cargo 0.4 for functional testing.pdf" data-linked-resource-default-alias="Vincent Massol Think Tank - Using Cargo 0.4 for functional testing.pdf" href="#">Using Cargo 0.4 for functional testing</a></li></ul>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced