Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed some links/typos

...

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.

 New New tests should be named using the Jira Issue 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: mng1234mng-1234-groupIdOrderIsBackwards.

This name is typically used in several places of the test: the folder in core-integration-tests/src/test/resources/ that contains the sample project along with the name of the junit class used to invoke the sample project and check the results.

...

A sample project has been created to aid in IT test creation. It can be retrieved using svn here or Subversion from our source repository or directly viewed with your browser herevia our SVN view.

Sample IT Archetype

This project has also been converted into an archetype to make it even easier to use.

...

No Format
|   pom.xml
|
\---src
    \---test
        +---java
        |   \---org
        |       \---apache
        |           \---maven
        |               \---integrationTestsintegrationtests
	|                     |   MavenITmngXXXXDescriptionOfProblemTest.java
        |
        \---resources
            \---mng-xxxx-descriptionOfProblem
                |   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

    The directory src/test/java/ contains a junit file used to execute the sample project. It is heavily commented to guide you along. Stop here and Take a look before continuing.

    The directory src/test/resources contains a sample project tree that will be invoked to test our condition. The sample consists of a few modules, first an extension (checkstyle-assembly) that is jarred up and installed into the repository. Then a second invocation is made on a project that uses the extension (checkstyle-test)

...

No Format
/cygdrive/e/svn/Maven/maven-it-tests/core-integration-tests
$ cp ../test/artifact/src . -R -v
`../test/artifact/src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java' -> `./src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/src/main/resources/rule_set.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/src/main/resources/rule_set.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/src/main/resources/stc_checks.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/src/main/resources/stc_checks.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/target/classes/rule_set.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/target/classes/rule_set.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/target/classes/stc_checks.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/target/classes/stc_checks.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/src/main/java/Class.java' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/src/main/java/Class.java'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml'
`../test/artifact/src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt' -> `./src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt'

Now add your test to the testSuite test suite by adding a new line to "src\test\java\org\apache\maven\integrationtests\IntegrationTestSuite.java"

No Format
 suite.addTestSuite( MavenItmngXXXXDescriptionOfProblemTestMavenITmngXXXXDescriptionOfProblemTest.class );

Now run the suite:

No Format
brianf@sonoma /cygdrive/e/svn/Maven/maven-it-tests/core-integration-test
$ 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-integration-tests\target\test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: e:\svn\Maven\maven-it-tests\core-integration-tests\target\surefire-reports
Running integration tests for Maven 2.0.7

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.apache.maven.integrationtests.IntegrationTestSuite
Running integration tests for Maven 2.0.7
0000(testit0000).. Ok
....
got get some coffee, it's gonna be a while
....
MavenItmngXXXXDescriptionOfProblemTestMavenITmngXXXXDescriptionOfProblemTest...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.integrationtests.MavenIT0002Test)

Tests in error:
  testit0086(org.apache.maven.integrationtests.MavenIT0086Test)
  testit0087(org.apache.maven.integrationtests.MavenIT0087Test)
  testit0104(org.apache.maven.integrationtests.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] ------------------------------------------------------------------------

Don't panic if some tests fail. That's probably normal. Only Panic panic if your test doesn't fail and it was supposed to (especially if you didn't write it).

...