Updated Branches: refs/heads/master 0cb28a6de -> 065da9ca6
o Added extraArtifacts, removed souts, simplified getInitalGoals I know this is 3 things at once, but it does not seem impossible after all Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/065da9ca Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/065da9ca Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/065da9ca Branch: refs/heads/master Commit: 065da9ca635cf23747da25164da872c3f1ef1a3c Parents: 0cb28a6 Author: Kristian Rosenvold <krosenv...@apache.org> Authored: Mon Dec 10 19:37:31 2012 +0100 Committer: Kristian Rosenvold <krosenv...@apache.org> Committed: Mon Dec 10 19:37:31 2012 +0100 ---------------------------------------------------------------------- .../surefire/its/fixture/SurefireLauncher.java | 77 +++++++-------- .../its/jiras/Surefire740TruncatedCommaIT.java | 1 - .../its/jiras/Surefire772BothReportsIT.java | 6 - .../its/jiras/Surefire772NoSurefireReportsIT.java | 8 -- .../its/jiras/Surefire772SpecifiedReportsIT.java | 6 - .../src/test/resources/working-directory/pom.xml | 3 +- surefire-setup-integration-tests/pom.xml | 54 ++++++++++- 7 files changed, 90 insertions(+), 65 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java index 0e4cedb..ed44849 100755 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java @@ -48,14 +48,14 @@ public class SurefireLauncher { private final List<String> cliOptions = new ArrayList<String>(); - private final List<String> goals = getInitialGoals(); - - private final Map<String, String> envvars = new HashMap<String, String>(); - private final String testNgVersion = System.getProperty( "testng.version" ); private final String surefireVersion = System.getProperty( "surefire.version" ); + private final List<String> goals = getInitialGoals( testNgVersion ); + + private final Map<String, String> envvars = new HashMap<String, String>(); + private Verifier verifier; private OutputValidator validator; @@ -76,8 +76,8 @@ public class SurefireLauncher this.resourceName = resourceName; this.suffix = suffix != null ? suffix : ""; goals.clear(); - goals.addAll( getInitialGoals() ); - cliOptions.clear(); + goals.addAll( getInitialGoals( testNgVersion ) ); + resetCliOptions(); } public SurefireLauncher( Verifier verifier ) @@ -87,8 +87,13 @@ public class SurefireLauncher this.suffix = ""; this.verifier = verifier; goals.clear(); - goals.addAll( getInitialGoals() ); - cliOptions.clear(); + goals.addAll( getInitialGoals( testNgVersion ) ); + resetCliOptions(); + } + + private void addCliOption( String cliOption ) + { + cliOptions.add( cliOption ); } private Verifier createVerifier( Class testClass, String resourceName ) @@ -122,7 +127,7 @@ public class SurefireLauncher { // dirty. Im sure we can use junit4 rules to attach testname to thread instead StackTraceElement[] stackTrace = getStackTraceElements(); - StackTraceElement topInTestClass = null; + StackTraceElement topInTestClass; topInTestClass = findTopElemenent( stackTrace, testClass ); if ( topInTestClass == null ) { @@ -164,8 +169,14 @@ public class SurefireLauncher public void reset() { goals.clear(); - goals.addAll( getInitialGoals() ); + goals.addAll( getInitialGoals( testNgVersion ) ); + resetCliOptions(); + } + + private void resetCliOptions() + { cliOptions.clear(); + offline(); } public SurefireLauncher getSubProjectLauncher( String subProject ) @@ -188,16 +199,16 @@ public class SurefireLauncher return this; } - private List<String> getInitialGoals() + private List<String> getInitialGoals( String testNgVersion1 ) { List<String> goals1 = new ArrayList<String>(); goals1.add( "-Dsurefire.version=" + surefireVersion ); if ( testNgVersion != null ) { - goals1.add( "-DtestNgVersion=" + testNgVersion ); + goals1.add( "-DtestNgVersion=" + testNgVersion1 ); - ArtifactVersion v = new DefaultArtifactVersion( testNgVersion ); + ArtifactVersion v = new DefaultArtifactVersion( testNgVersion1 ); try { if ( VersionRange.createFromVersionSpec( "(,5.12.1)" ).containsVersion( v ) ) @@ -214,32 +225,10 @@ public class SurefireLauncher return goals1; } - // Todo remove duplication between this and getInitialGoals public SurefireLauncher resetInitialGoals( String testNgVersion ) { - List<String> goals = new ArrayList<String>(); - goals.add( "-Dsurefire.version=" + surefireVersion ); - - if ( testNgVersion != null ) - { - goals.add( "-DtestNgVersion=" + testNgVersion ); - - ArtifactVersion v = new DefaultArtifactVersion( testNgVersion ); - try - { - if ( VersionRange.createFromVersionSpec( "(,5.12.1)" ).containsVersion( v ) ) - { - goals.add( "-DtestNgClassifier=jdk15" ); - } - } - catch ( InvalidVersionSpecificationException e ) - { - throw new RuntimeException( e.getMessage(), e ); - } - } - this.goals.clear(); - this.goals.addAll( goals ); + this.goals.addAll( getInitialGoals( testNgVersion ) ); return this; } @@ -252,13 +241,13 @@ public class SurefireLauncher public SurefireLauncher showErrorStackTraces() { - cliOptions.add( "-e" ); + addCliOption( "-e" ); return this; } public SurefireLauncher debugLogging() { - cliOptions.add( "-X" ); + addCliOption( "-X" ); return this; } @@ -270,9 +259,14 @@ public class SurefireLauncher public SurefireLauncher failNever() { - cliOptions.add( "-fn" ); + addCliOption( "-fn" ); return this; + } + public SurefireLauncher offline() + { + addCliOption( "-o" ); + return this; } public SurefireLauncher skipClean() @@ -296,6 +290,7 @@ public class SurefireLauncher public OutputValidator executeTest() { + addCliOption( "-o" ); return execute( "test" ); } @@ -374,7 +369,7 @@ public class SurefireLauncher } - cliOptions.add( "-s " + interpolatedSettings.getCanonicalPath() ); + addCliOption( "-s " + interpolatedSettings.getCanonicalPath() ); } getVerifier().setCliOptions( cliOptions ); @@ -539,7 +534,7 @@ public class SurefireLauncher public SurefireLauncher setEOption() { - cliOptions.add( "-e" ); + addCliOption( "-e" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java index fa8c9a3..f2eea47 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java @@ -37,7 +37,6 @@ public class Surefire740TruncatedCommaIT "-Duser.language=ru -Duser.country=RU" ).failNever().addSurefireReportGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting file", siteFile.exists() ); siteFile.assertContainsText( "027" ); // Avoid asserting with the "," or "." ;) } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java index 1c830d1..e3e0463 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java @@ -45,11 +45,9 @@ public class Surefire772BothReportsIT unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = outputValidator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting surefire report file", siteFile.isFile() ); siteFile = outputValidator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } @@ -61,11 +59,9 @@ public class Surefire772BothReportsIT "skipFailsafe" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no failsafe report file", siteFile.isFile() ); } @@ -77,11 +73,9 @@ public class Surefire772BothReportsIT "skipSurefire" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java index 89b8ef4..a6e69ff 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java @@ -38,11 +38,9 @@ public class Surefire772NoSurefireReportsIT unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } @@ -52,11 +50,9 @@ public class Surefire772NoSurefireReportsIT "skipSurefire" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } @@ -66,11 +62,9 @@ public class Surefire772NoSurefireReportsIT "optionalSurefire" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } @@ -80,11 +74,9 @@ public class Surefire772NoSurefireReportsIT "skipSurefire" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java index 00aaa3e..ac94032 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java @@ -38,11 +38,9 @@ public class Surefire772SpecifiedReportsIT unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } @@ -52,11 +50,9 @@ public class Surefire772SpecifiedReportsIT "skipFailsafe" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no failsafe report file", siteFile.isFile() ); } @@ -66,11 +62,9 @@ public class Surefire772SpecifiedReportsIT "skipSurefire" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals(); TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertFalse( "Expecting no surefire report file", siteFile.isFile() ); siteFile = validator.getSiteFile( "failsafe-report.html" ); - System.out.println( "siteFile.getAbsolutePath() = " + siteFile.getAbsolutePath() ); assertTrue( "Expecting failsafe report file", siteFile.isFile() ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-integration-tests/src/test/resources/working-directory/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/working-directory/pom.xml b/surefire-integration-tests/src/test/resources/working-directory/pom.xml index 6b27060..318097e 100644 --- a/surefire-integration-tests/src/test/resources/working-directory/pom.xml +++ b/surefire-integration-tests/src/test/resources/working-directory/pom.xml @@ -33,13 +33,12 @@ </modules> <build> - <plugins> + <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${surefire.version}</version> </plugin> - </plugins> </build> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/065da9ca/surefire-setup-integration-tests/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml index 543afa9..2fad52f 100644 --- a/surefire-setup-integration-tests/pom.xml +++ b/surefire-setup-integration-tests/pom.xml @@ -66,7 +66,7 @@ <artifactId>surefire-testng</artifactId> <version>${project.version}</version> <exclusions> - <!-- SC don't want our surefire getting confulsed and trying to use the testng runner --> + <!-- SC don't want our surefire getting confused and trying to use the testng runner --> <exclusion> <groupId>org.testng</groupId> <artifactId>testng</artifactId> @@ -139,6 +139,58 @@ <extraArtifact>org.apache.maven.surefire:surefire-testng-utils:${project.version}</extraArtifact> </extraArtifacts> <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath> + <extraArtifacts> + <extraArtifact>org.testng:testng:4.7:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.0.2:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.1:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.5:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.6:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.7:jar:jdk14</extraArtifact> + <extraArtifact>org.testng:testng:5.7:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.8:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.9:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.10:jar:jdk15</extraArtifact> + <extraArtifact>org.testng:testng:5.12.1</extraArtifact> + <extraArtifact>org.testng:testng:5.13</extraArtifact> + <extraArtifact>org.testng:testng:5.13.1</extraArtifact> + <extraArtifact>org.testng:testng:5.14</extraArtifact> + <extraArtifact>org.testng:testng:5.14.1</extraArtifact> + <extraArtifact>org.testng:testng:5.14.2</extraArtifact> + <extraArtifact>org.testng:testng:5.14.9</extraArtifact> + <extraArtifact>org.testng:testng:6.0</extraArtifact> + <extraArtifact>org.testng:testng:6.5.1</extraArtifact> + <extraArtifact>com.google.inject:guice:3.0:jar:no_aop</extraArtifact> + <extraArtifact>log4j:log4j:1.2.16</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4.1</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-compiler-plugin:2.3.2</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-compiler-plugin:2.5.1</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-install-plugin:2.3.1</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-compiler-plugin:2.0.2</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-resources-plugin:2.5</extraArtifact> + <extraArtifact>org.apache.maven.plugins:maven-jar-plugin:2.3.2</extraArtifact> + <extraArtifact>org.apache.commons:commons-email:1.2</extraArtifact> + <extraArtifact>org.codehaus.mojo:build-helper-maven-plugin:1.2</extraArtifact> + <extraArtifact>org.apache.maven.reporting:maven-reporting-api:2.0.9</extraArtifact> + <extraArtifact>commons-collections:commons-collections:3.2</extraArtifact> + <extraArtifact>commons-logging:commons-logging:1.0.4</extraArtifact> + <extraArtifact>xml-apis:xml-apis:1.0.b2</extraArtifact> + <extraArtifact>org.apache.httpcomponents:httpclient:4.0.2</extraArtifact> + <extraArtifact>junit:junit:4.4</extraArtifact> + <extraArtifact>junit:junit:4.5</extraArtifact> + <extraArtifact>junit:junit:4.7</extraArtifact> + <extraArtifact>junit:junit:4.8.1</extraArtifact> + <extraArtifact>junit:junit:4.8.2</extraArtifact> + <extraArtifact>junit:junit:4.11</extraArtifact> + <extraArtifact>junit:junit-dep:4.8</extraArtifact> + <extraArtifact>junit:junit-dep:4.7</extraArtifact> + <extraArtifact>junit:junit-dep:4.4</extraArtifact> + <!--- W00t! This is for the WorkingDirectoryInvalid test that will use mavens default surefire version --> + <extraArtifact>org.apache.maven.plugins:maven-surefire-plugin:2.10</extraArtifact> + <extraArtifact>org.apache.maven.surefire:surefire-junit3:2.10</extraArtifact> + <extraArtifact>org.codehaus.plexus:plexus-utils:1.0.4</extraArtifact> + <extraArtifact>org.codehaus.plexus:plexus-utils:1.5.1</extraArtifact> + <extraArtifact>org.mockito:mockito-core:1.8.5</extraArtifact> + </extraArtifacts> </configuration> <executions> <execution>