maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1040710 - in /maven/surefire/trunk/surefire-integration-tests/src/test: java/org/apache/maven/surefire/its/ resources/result-counting/ resources/result-counting/src/ resources/result-counting/src/test/ resources/result-counting/src/test/ja...
Date Tue, 30 Nov 2010 19:11:20 GMT
Author: krosenvold
Date: Tue Nov 30 19:11:19 2010
New Revision: 1040710

URL: http://svn.apache.org/viewvc?rev=1040710&view=rev
Log:
o Added integrationtest for result counting in forkmodes

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/pom.xml
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest1.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest2.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest3.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test1.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test2.java
  (with props)

Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,86 @@
+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.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+import org.apache.maven.reporting.MavenReportException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Verifies that the providers get the result summary at the bottom of the run correctly,
in different forkmodes
+ * SUREFIRE-613 Asserts proper test counts when running in parallel
+ *
+ * @author Kristian Rosenvold
+ */
+public class ResultCountingIT
+    extends AbstractSurefireIntegrationTestClass
+{
+    public void testCountingWithJunit481ForkNever()
+        throws Exception
+    {
+        assertForkMode( "never" );
+    }
+
+    public void testCountingWithJunit481ForkOnce()
+        throws Exception
+    {
+        assertForkMode( "once" );
+    }
+
+
+    public void testCountingWithJunit481ForkAlways()
+        throws Exception
+    {
+        assertForkMode( "always" );
+    }
+
+    private void assertForkMode( String forkMode )
+        throws IOException, VerificationException, MavenReportException
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/result-counting"
);
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        String[] opts = { "-fn" };
+        verifier.setCliOptions( new ArrayList( Arrays.asList( opts ) ) );
+        List goals = getGoals( forkMode );
+        this.executeGoals( verifier, goals );
+
+        verifier.resetStreams();
+
+        HelperAssertions.assertTestSuiteResults( 36, 23, 4, 2, testDir );
+
+        verifier.verifyTextInLog( "Tests run: 36, Failures: 4, Errors: 23, Skipped: 2" );
+    }
+
+    private List getGoals( String forkMode )
+    {
+        List goals = this.getInitialGoals();
+        goals.add( "test" );
+        goals.add( "-DforkMode=" + forkMode );
+        return goals;
+    }
+}
\ No newline at end of file

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/pom.xml?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/pom.xml
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/pom.xml
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,47 @@
+<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>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>junit4-test</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+    </dependency>
+  </dependencies>
+  <build>
+     <plugins>
+        <plugin>
+           <groupId>org.apache.maven.plugins</groupId>
+           <artifactId>maven-compiler-plugin</artifactId>
+           <configuration>
+              <source>1.5</source>
+              <target>1.5</target>
+           </configuration>
+        </plugin>
+        <plugin>
+           <groupId>org.apache.maven.plugins</groupId>
+           <artifactId>maven-surefire-plugin</artifactId>
+           <version>${surefire.version}</version>
+           <configuration>
+             <forkMode>${forkMode}</forkMode>
+             <includes>
+                <include>**/Test*.java</include>
+               <include>**/MySuiteTest1.java</include>
+               <include>**/MySuiteTest2.java</include>
+               <include>**/MySuiteTest3.java</include>
+             </includes>
+           </configuration>
+        </plugin>
+     </plugins>
+  </build>
+  <properties>
+    <junit.version>4.8.1</junit.version>
+    <forkMode>once</forkMode>
+  </properties>
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest1.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest1.java?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest1.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest1.java
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,27 @@
+package resultcounting;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class MySuiteTest1 extends TestCase {
+
+    public static Test suite () {
+        TestSuite suite = new TestSuite();
+
+        suite.addTest (new MySuiteTest1("testMe", 1));
+
+        return suite;
+    }
+
+    private int number;
+
+    public MySuiteTest1(String name, int number) {
+        super (name);
+        this.number = number;
+    }
+
+    public void testMe() {
+        assertTrue (true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest2.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest2.java?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest2.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest2.java
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,28 @@
+package resultcounting;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class MySuiteTest2 extends TestCase {
+
+    public static Test suite () {
+        TestSuite suite = new TestSuite();
+
+        suite.addTest (new MySuiteTest2("testMe", 1));
+        suite.addTest (new MySuiteTest2("testMe", 2));
+
+        return suite;
+    }
+
+    private int number;
+
+    public MySuiteTest2(String name, int number) {
+        super (name);
+        this.number = number;
+    }
+
+    public void testMe() {
+        assertTrue (true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest3.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest3.java?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest3.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest3.java
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,29 @@
+package resultcounting;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class MySuiteTest3 extends TestCase {
+
+    public static Test suite () {
+        TestSuite suite = new TestSuite();
+
+        suite.addTest (new MySuiteTest3("testMe", 1));
+        suite.addTest (new MySuiteTest3("testMe", 2));
+        suite.addTest (new MySuiteTest3("testMe", 3));
+
+        return suite;
+    }
+
+    private int number;
+
+    public MySuiteTest3(String name, int number) {
+        super (name);
+        this.number = number;
+    }
+
+    public void testMe() {
+        assertTrue (true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/MySuiteTest3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test1.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test1.java?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test1.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test1.java
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,58 @@
+package resultcounting;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assume.*;
+import junit.framework.TestCase;
+
+public class Test1 extends TestCase
+{
+    public void testWithFailingAssumption1() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption2() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption3() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption4() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption5() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption6() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption7() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption8() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption9() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption10() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption11() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption12() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption13() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption14() {
+        assumeThat( 2, is(3));
+    }
+    public void testWithFailingAssumption15() {
+        assumeThat( 2, is(3));
+    }
+}
\ No newline at end of file

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test2.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test2.java?rev=1040710&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test2.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test2.java
Tue Nov 30 19:11:19 2010
@@ -0,0 +1,84 @@
+package resultcounting;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assume.*;
+import static junit.framework.Assert.fail;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class Test2 
+{
+    @Test
+    public void testAllok(){
+        System.out.println("testAllok to stdout");
+        System.err.println("testAllok to stderr");
+    }
+
+
+    @Ignore
+    @Test
+    public void testWithIgnore1(){
+    }
+
+    @Ignore
+    @Test
+    public void testWithIgnore2(){
+    }
+
+    @Test
+    public void testiWithFail1(){
+        fail("We excpect this");
+    }
+    @Test
+    public void testiWithFail2(){
+        fail("We excpect this");
+    }
+    @Test
+    public void testiWithFail3(){
+        fail("We excpect this");
+    }
+    @Test
+    public void testiWithFail4(){
+        fail("We excpect this");
+    }
+
+    @Test
+    public void testWithException1() {
+        System.out.println("testWithException1 to stdout");
+        System.err.println("testWithException1 to stderr");
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException2() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException3() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException4() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException5() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException6() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException7() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException8() {
+        throw new RuntimeException("We expect this");
+    }
+
+}
\ No newline at end of file

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/result-counting/src/test/java/resultcounting/Test2.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message