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
Sign Up
Dashboard
Maven
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
<h3>Naming your Test</h3> <p>In the past, tests were numbered sequentially (it001,it002, etc). This becomes problematic because it's not always obvious what the issue is related to the test. More importantly, it's hard to create and submit sequential tests via patches because non-committers have no way to reserve the next number. This leads to extra work to apply the patch.</p> <p>New tests should be named using the JIRA issue id along with a meaningful name. This name should typically be the subject of the issue or a subset. It should be informative of the issue but not excessively long. Therefore a good name would be: <code>MavenITmng1234groupIdOrderIsBackwardsTest</code>. The corresponding resource directory for this test in <code>core-it-suite/src/test/resources/</code> would simply be named <code>mng-1234</code>, i.e. without the description to keep the path short.</p> <h3>Sample IT Project</h3> <p>A sample project has been created to aid in IT test creation. It can be retrieved using Subversion from our <a href="http://svn.apache.org/repos/asf/maven/core-integration-testing/trunk/core-it-support/maven-it-sample/">source repository</a> or directly viewed with your browser via our <a href="http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-sample/">SVN view</a>.</p> <h3>Sample IT Archetype</h3> <p>This project has also been converted into an archetype to make it even easier to use.</p> <blockquote> <p>It would be helpful to review the archetype plugin documentation here: <a class="external-link" href="http://maven.apache.org/plugins/maven-archetype-plugin/" rel="nofollow">http://maven.apache.org/plugins/maven-archetype-plugin/</a></p></blockquote> <p>The Archetype Plugin doesn't currently know about this archetype, so we created a catalog file to be used.</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> mvn archetype:generate -DarchetypeCatalog=http://docs.codehaus.org/download/attachments/1835439/archetype-catalog.xml </pre></td></tr></table> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> $ mvn archetype:generate -DarchetypeCatalog=http://docs.codehaus.org/download/attachments/1835439/archetype-catalog.xml [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:generate] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:generate] Choose archetype: 1: remote -> maven-it-sample-archetype (Archetype for creating a Maven 2 Integration Test) Choose a number: (1): 1 [INFO] snapshot org.apache.maven.its:maven-it-sample-archetype:1.0-SNAPSHOT: checking for updates from maven-it-sample-archetype-repo Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/apache/maven/its/maven-it-sample-archetype/1.0-SNAPSHOT/maven-it-sample-archetype-1.0-20080303.190914-2.jar 9K downloaded Define value for groupId: : org.apache.maven.its Define value for artifactId: : my-it Define value for version: : 1 Define value for package: : org.apache.maven.it Confirm properties configuration: groupId: org.apache.maven.its artifactId: my-it version: 1 package: org.apache.maven.it Y: : Y [WARNING] org.apache.velocity.runtime.exception.ReferenceException: reference : template = archetype-resources/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml [line 42,column 26] : ${project.build.directory} is not a valid reference. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 44 seconds [INFO] Finished at: Mon Mar 03 19:13:41 GMT 2008 [INFO] Final Memory: 10M/28M [INFO] ------------------------------------------------------------------------ </pre></td></tr></table> <p>The project will be created in a subfolder of your current directory with the name you chose for the artifact. (my-it in the above example).</p> <h3>Tour of the Sample Project</h3> <p>The sample IT project contains the following files: </p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> | pom.xml | \---src \---test +---java | \---org | \---apache | \---maven | \---it | | MavenITmngXXXXDescriptionOfProblemTest.java | \---resources \---mng-xxxx | pom.xml | readme.txt | +---checkstyle-assembly | | pom.xml | | | +---src | \---main | \---resources | rule_set.xml | stc_checks.xml | | | \---checkstyle-test | pom.xml | \---src \---main \---java Class.java </pre></td></tr></table> <p>The directory <code>src/test/java/</code> contains a junit file used to execute the sample project. It is heavily commented to guide you along. Stop here and <a href="http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-sample/src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java?view=markup">Take a look</a> before continuing.</p> <p>The directory <code>src/test/resources</code> contains a sample project tree that will be invoked to test our condition. The sample consists of a few modules, first an extension (<a href="http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-sample/src/test/resources/mng-xxxx/checkstyle-assembly/pom.xml?view=markup">checkstyle-assembly</a>) that is jarred up and installed into the repository. Then a second invocation is made on a project that uses the extension (<a href="http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-sample/src/test/resources/mng-xxxx/checkstyle-test/pom.xml?view=markup">checkstyle-test</a>)</p> <p>The sample IT project uses the simplest method of using the verifier, that is the sample build fails if the test should fail. More complicated ITs can be created with beanshell scripts to check complex conditions. (Example Needed) (Link to verifier docs)</p> <p>Once your IT is complete, you should be able to execute it:</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> >mvn test [INFO] Scanning for projects... [INFO] ---------------------------------------------------------------------------- [INFO] Building Maven Integration Tests [INFO] task-segment: [test] [INFO] ---------------------------------------------------------------------------- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] No sources to compile [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] Compiling 1 source file to E:\svn\Maven\maven-it-tests\test\artifact\target\test-classes [INFO] [surefire:test] [INFO] Surefire report directory: E:\svn\Maven\maven-it-tests\test\artifact\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.apache.maven.it.MavenITmngXXXXDescriptionOfProblemTest mngXXXXDescriptionOfProblem(testitMNGxxxx).. OK Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 16.802 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 25 seconds [INFO] Finished at: Wed Aug 08 22:47:44 EDT 2007 [INFO] Final Memory: 4M/10M [INFO] ------------------------------------------------------------------------ </pre></td></tr></table> <h4>Submitting your IT Test</h4> <p>Now that your IT is complete, create a zip, tgz or some other *normal* archive of your test and attach it to your JIRA issue.</p> <p>If you are a Maven committer, read the next section to see how to integrate your test into the core, or to apply someone else's test.</p> <h3>Integrating an IT into the core-integration-tests</h3> <p>First, check out the <a href="http://svn.apache.org/repos/asf/maven/core-integration-testing/trunk/core-it-suite">core-it-suite</a> </p> <p>The sample project maps directly to the core-it-suite structure. Assuming the test has been named uniquely, you can copy the contents of src/test directly over to core-it-suite (don't copy from the root or you'll overwrite the POM). </p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> /cygdrive/e/svn/Maven/maven-it-tests/core-it-suite $ cp ../test/artifact/src . -R -v `../test/artifact/src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java' -> `./src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-assembly/pom.xml' -> `./src/test/resources/mng-xxxx/checkstyle-assembly/pom.xml' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-assembly/src/main/resources/rule_set.xml' -> `./src/test/resources/mng-xxxx/checkstyle-assembly/src/main/resources/rule_set.xml' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-assembly/src/main/resources/stc_checks.xml' -> `./src/test/resources/mng-xxxx/checkstyle-assembly/src/main/resources/stc_checks.xml' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-assembly/target/classes/rule_set.xml' -> `./src/test/resources/mng-xxxx/checkstyle-assembly/target/classes/rule_set.xml' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-assembly/target/classes/stc_checks.xml' -> `./src/test/resources/mng-xxxx/checkstyle-assembly/target/classes/stc_checks.xml' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-test/pom.xml' -> `./src/test/resources/mng-xxxx/checkstyle-test/pom.xml' `../test/artifact/src/test/resources/mng-xxxx/checkstyle-test/src/main/java/Class.java' -> `./src/test/resources/mng-xxxx/checkstyle-test/src/main/java/Class.java' `../test/artifact/src/test/resources/mng-xxxx/pom.xml' -> `./src/test/resources/mng-xxxx/pom.xml' `../test/artifact/src/test/resources/mng-xxxx/readme.txt' -> `./src/test/resources/mng-xxxx/readme.txt' </pre></td></tr></table> <p>Now add your test to the test suite by adding a new line to <code>src\test\java\org\apache\maven\it\IntegrationTestSuite.java</code></p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> suite.addTestSuite( MavenITmngXXXXDescriptionOfProblemTest.class ); </pre></td></tr></table> <p>Now run the suite:</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> brianf@sonoma /cygdrive/e/svn/Maven/maven-it-tests/core-it-suite $ mvn test [INFO] Scanning for projects... [INFO] ---------------------------------------------------------------------------- [INFO] Building Maven Integration Tests [INFO] task-segment: [test] [INFO] ---------------------------------------------------------------------------- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] No sources to compile [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] Compiling 124 source files to e:\svn\Maven\maven-it-tests\core-it-suite\target\test-classes [INFO] [surefire:test] [INFO] Surefire report directory: e:\svn\Maven\maven-it-tests\core-it-suite\target\surefire-reports Running integration tests for Maven 2.0.7 ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.apache.maven.it.IntegrationTestSuite Running integration tests for Maven 2.0.7 0000(testit0000).. Ok .... got get some coffee, it's gonna be a while .... MavenITmngXXXXDescriptionOfProblemTest...OK <-- our test...yeah! Tests run: 115, Failures: 22, Errors: 3, Skipped: 0, Time elapsed: 534.241 sec <<< FAILURE! Results : Failed tests: testit0002(org.apache.maven.it.MavenIT0002Test) Tests in error: testit0086(org.apache.maven.it.MavenIT0086Test) testit0087(org.apache.maven.it.MavenIT0087Test) testit0104(org.apache.maven.it.MavenIT0104Test) Tests run: 115, Failures: 22, Errors: 3, Skipped: 0 [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] There are test failures. [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 9 minutes 12 seconds [INFO] Finished at: Wed Aug 08 23:39:48 EDT 2007 [INFO] Final Memory: 4M/12M [INFO] ------------------------------------------------------------------------ </pre></td></tr></table> <p>Don't panic if some tests fail. That's probably normal. Only panic if your test doesn't fail and it was supposed to (especially if you didn't write it).</p> <p>Now add all those new files to svn (you can figure this one out on your own by now...you're an expert...and its late here) and commit.</p>
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