You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by kr...@apache.org on 2010/12/18 18:52:20 UTC
svn commit: r1050686 - in
/maven/surefire/trunk/surefire-integration-tests/src/test:
java/org/apache/maven/surefire/its/ resources/fork-consoleOutput/
resources/fork-consoleOutput/src/ resources/fork-consoleOutput/src/test/
resources/fork-consoleOutput...
Author: krosenvold
Date: Sat Dec 18 17:52:20 2010
New Revision: 1050686
URL: http://svn.apache.org/viewvc?rev=1050686&view=rev
Log:
o Made a generalized fork-consoleOutput IT test to test console output
in forkmodes.
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml (contents, props changed)
- copied, changed from r1050534, maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/Test1.java (contents, props changed)
- copied, changed from r1050534, maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/src/test/java/surefire639/Test1.java
Removed:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/src/test/java/surefire639/Test1.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/src/test/java/surefire639/Test2.java
Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java?rev=1050686&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java Sat Dec 18 17:52:20 2010
@@ -0,0 +1,64 @@
+package org.apache.maven.surefire.its;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.maven.it.Verifier;
+
+/**
+ * Asserts proper behaviour of console output when forking
+ * SUREFIRE-639
+ * SUREFIRE-651
+ *
+ * @author Kristian Rosenvold
+ */
+public class ForkConsoleOutputIT
+ extends SurefireVerifierTestClass
+{
+
+ public ForkConsoleOutputIT()
+ {
+ super( "/fork-consoleOutput" );
+ }
+
+ public void testPrintSummaryTrue()
+ throws Exception
+ {
+ redirectToFile(true);
+ printSummary(true);
+
+ Verifier verifier = execute("test");
+ verifier.verifyTextInLog( "Test1" );
+ verifier.assertFilePresent( getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) );
+ }
+
+ private void printSummary(boolean printsummary)
+ {
+ addGoal( "-DprintSummary=" + printsummary);
+ }
+
+ private void redirectToFile(boolean redirect)
+ {
+ addGoal( "-Dredirect.to.file=" + redirect );
+ }
+ private void forkMode(String forkMode)
+ {
+ addGoal( "-DforkMode=" + forkMode);
+ }
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java?rev=1050686&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java Sat Dec 18 17:52:20 2010
@@ -0,0 +1,96 @@
+package org.apache.maven.surefire.its;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Contains commonly used featurtes for most tests, encapsulating
+ * common use cases
+ *
+ * @author Kristian Rosenvold
+ */
+public abstract class SurefireVerifierTestClass
+ extends AbstractSurefireIntegrationTestClass
+{
+ private final String testProject;
+ private final File testDir;
+ private final List cliOptions = new ArrayList( );
+ private final List goals;
+ private final Verifier verifier;
+
+
+ protected SurefireVerifierTestClass( String testProject )
+ {
+ try
+ {
+ this.testProject = testProject;
+ testDir = ResourceExtractor.simpleExtractResources( getClass(), "/fork-consoleOutput" );
+ this.goals = getInitialGoals();
+ this.verifier = new Verifier( testDir.getAbsolutePath() );
+ }
+ catch ( VerificationException e )
+ {
+ throw new RuntimeException( e );
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+ protected SurefireVerifierTestClass failNever(){
+ cliOptions.add( "-fn" );
+ return this;
+ }
+ protected SurefireVerifierTestClass addGoal(String goal){
+ goals.add( goal );
+ return this;
+ }
+
+ protected Verifier execute(String goal)
+ throws VerificationException
+ {
+ addGoal( goal);
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoals( goals );
+ verifier.resetStreams();
+ return verifier;
+ }
+
+ protected String getSurefireReportsFile(String fileName){
+ File targetDir = new File( testDir, "target/surefire-reports" );
+ File target= new File( targetDir, fileName);
+ return target.getAbsolutePath();
+ }
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml (from r1050534, maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/pom.xml)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml&p1=maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/pom.xml&r1=1050534&r2=1050686&rev=1050686&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml Sat Dec 18 17:52:20 2010
@@ -1,17 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>mag</groupId>
- <artifactId>junit4-test</artifactId>
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>fork-consoleOutput</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
- <name>junit4-test</name>
+ <name>fork-consoleOutput</name>
<url>http://maven.apache.org</url>
- <properties>
- <junit.version>4.8.1</junit.version>
- <redirect.to.file>true</redirect.to.file>
- <forkMode>once</forkMode>
- </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
@@ -35,6 +31,7 @@
<version>${surefire.version}</version>
<configuration>
<forkMode>${forkMode}</forkMode>
+ <printSummary>${printSummary}</printSummary>
<redirectTestOutputToFile>${redirect.to.file}</redirectTestOutputToFile>
<includes>
<include>**/Test*.java</include>
@@ -42,5 +39,14 @@
</configuration>
</plugin>
</plugins>
+
</build>
+
+ <properties>
+ <junit.version>4.8.1</junit.version>
+ <redirect.to.file>true</redirect.to.file>
+ <forkMode>once</forkMode>
+ <printSummary>true</printSummary>
+ </properties>
+
</project>
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/Test1.java (from r1050534, maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/src/test/java/surefire639/Test1.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/Test1.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/Test1.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/src/test/java/surefire639/Test1.java&r1=1050534&r2=1050686&rev=1050686&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-639-redirectTestOutputToFileWhenForking/src/test/java/surefire639/Test1.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/Test1.java Sat Dec 18 17:52:20 2010
@@ -1,4 +1,4 @@
-package surefire639;
+package forkConsoleOutput;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -32,17 +32,17 @@ public class Test1
{
@Test
public void test6281() {
- System.out.println( "628Test1 on" + Thread.currentThread().getName());
+ System.out.println( "Test1 on" + Thread.currentThread().getName());
}
@BeforeClass
public static void testWithFailingAssumption2() {
- System.out.println( "Before628Test1 on" + Thread.currentThread().getName());
+ System.out.println( "BeforeTest1 on" + Thread.currentThread().getName());
}
@AfterClass
public static void testWithFailingAssumption3() {
- System.out.println( "After628Test1 on" + Thread.currentThread().getName());
+ System.out.println( "AfterTest1 on" + Thread.currentThread().getName());
}
}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/src/test/java/forkConsoleOutput/Test1.java
------------------------------------------------------------------------------
svn:eol-style = native