@@ -2,38 +2,38 @@ Testing maven-eclipse-plugin
22
33 This is a complicated beast, it generates a bunch of different files (all in different formats: text, xml)
44 that have hard coded paths and other junk in them.
5-
5+
66 Most of the work is done in the integration tests.
77
88 You have to set M2_HOME to the appropriate maven version
99 you want to test with like this:
10-
10+
1111 export M2_HOME=/usr/share/java/apache-maven-3.1.1
12-
13- Use
12+
13+ Use
1414 mvn -Prun-its verify
1515 to run the integration tests
16-
16+
1717 One day these tests will be unified into whatever "sanctioned" way of doing integration tests becomes.
18-
18+
1919Running a single test
20- * Run mvn and tell surefire to only run your TestCase:
20+ * Run mvn and tell surefire to only run your TestCase:
2121
2222 (See http://maven.apache.org/plugins/maven-surefire-plugin/examples/single-test.html for more details)
23-
23+
2424 mvn -Prun-its integration-test -Dit.test=EclipsePluginIT#testProject10
25-
25+
2626PluginTestTool
2727 The bulk of the integration tests are using the old (and obsoleted) method of PluginTestTool.
28- These IT tests are invoked via maven-failsafe-plugin:integration-test which looks for JUnit test cases
28+ These IT tests are invoked via maven-failsafe-plugin:integration-test which looks for JUnit test cases
2929 from the ${project.build.testSourceDirectory} of the form:
3030 (see http://maven.apache.org/plugins/maven-failsafe-plugin/integration-test-mojo.html#includes)
3131 <includes>
3232 <include>**/IT*.java</include>
3333 <include>**/*IT.java</include>
3434 <include>**/*ITCase.java</include>
35- </includes>
36-
35+ </includes>
36+
3737 The test classes all extends AbstractEclipsePluginIT which initialised the testing area with a test
3838 version of the plugin under test. Each actual test then needs to specify which test project should be run
3939 in a test method. e.g. EclipsePluginIT has methods like:
@@ -42,73 +42,73 @@ PluginTestTool
4242 {
4343 testProject( "project-63-MECLIPSE-388" );
4444 }
45- which delegates to AbstractEclipsePluginIT.testProject() and specifies the test project directory that should
45+ which delegates to AbstractEclipsePluginIT.testProject() and specifies the test project directory that should
4646 be used. All test projects are located in src/test/resources/projects/, so in this example it would be
4747 src/test/resources/projects/project-63-MECLIPSE-388
48-
48+
4949 Each test project needs a pom.xml file. It's easiest to copy and hack an existing file from another working test project.
5050 These test projects will not pollute your local ~/.m2/repository. A separate test repository inside target/ is created
5151 that will house all the downloaded artifacts and installed test projects.
52-
52+
5353 A negative consequence of using PluginTestTool is that anything downloaded from central is not stored in
5454 your ~/.m2/repository which means wasted bandwidth after doing "mvn clean".
55-
55+
5656 Remember that your build/plugins/plugin for maven-eclipse-plugin needs:
5757 <version>test</version>
5858 for PluginTestTool to work. You may need additional configuration settings,
5959 like workspace so that you dont accidentally pollute your tests with settings
6060 from your actual eclipse workspace used to develop this plugin.
61-
61+
6262* Validating a successful test
6363
6464 Each test will automatically run a comparison of the generated files.
65- A generated file will only be verified if the same file (including path hierarchy) exists in the
65+ A generated file will only be verified if the same file (including path hierarchy) exists in the
6666 under the "expected" directory. e.g. src/test/resources/project-63-MECLIPSE-388/expected contains:
6767 * settings/org.eclipse.jdt.core.prefs
6868 * .classpath
6969 * .project
70-
70+
7171 Before comparison is done, each file (both expected and actual) is preprocessed via
7272 AbstractEclipsePluginIT.preprocess( File file, Map variables ) which
7373 * removes windows drive details
7474 * replaces any variables with their values, currently only "${basedir}" and "${M2_REPO}" are supported variable.
75- * specific hacks for specific files like eclipse *.prefs files and wst files.
75+ * specific hacks for specific files like eclipse *.prefs files and wst files.
7676 See the method for more details.
77-
78- The comparator read the first few bytes of the actual file to see if it contains an XML header, and
77+
78+ The comparator read the first few bytes of the actual file to see if it contains an XML header, and
7979 if so uses XMLAssert to compare the contents of the file. This allows for variation in ordering
8080 but the contents must be the same.
81-
81+
8282 If the file name is ".classpath" then an assertXMLIdentical comparison is made, otherwise XMLAssert.assertXMLEqual
83- is used (which is lenient about the ordering of the XML but requires the same contents)
84-
83+ is used (which is lenient about the ordering of the XML but requires the same contents)
84+
8585 All other cases do a text file comparison.
86-
86+
8787Invoker
88- Some tests are done via invoker.
89-
88+ Some tests are done via invoker.
89+
9090 If you are behind a firewall then you must configure src/it/settings.xml.
9191 Do this by copying src/it/settings-default to settings-${user.name}.xml.
92- The pom's process-resources configuration will copy this to src/it/settings.xml for you.
93-
94- (TODO: Someone who understands how invoker works - can you complete this section)
95-
92+ The pom's process-resources configuration will copy this to src/it/settings.xml for you.
93+
94+ (TODO: Someone who understands how invoker works - can you complete this section)
95+
9696Running surefire-report:report-only
9797
9898 After running the integration tests you can run surefire-report:report-only to build a report of the test success/failures.
9999 Then open target\site\surefire-report.html for more details.
100-
100+
101101Creating expected files
102102
103103 The antrun plugin has been bound to the phase "post-integration-test" and will invoke the bean shell script
104- "verify-integration-tests-checks.bsh". This script will ensure that each generated file (that is knows about)
104+ "verify-integration-tests-checks.bsh". This script will ensure that each generated file (that is knows about)
105105 that exists in your test project directories has a corresponding expected file.
106-
107- When the expected file does not yet exist it will "seed" the src/test/resources project expected directory with the
108- one actually generated by the test run.
109-
106+
107+ When the expected file does not yet exist it will "seed" the src/test/resources project expected directory with the
108+ one actually generated by the test run.
109+
110110 YOU MUST CHECK THIS FILE.
111-
111+
112112 When you go to check in changes these files should show up as requiring adding to version control.
113113 Please make sure you ensure that these files have been customized with variables so they work in anyones environment.
114-
114+
0 commit comments