[ 
https://jira.codehaus.org/browse/SUREFIRE-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=340779#comment-340779
 ] 

Andreas Gudian commented on SUREFIRE-1059:
------------------------------------------

I think Tibor mentioned in the other ticket that he intents to improve the 
configuration capabilities. So it's on the list :-). 

I'll close the issue for now.

> Running tests in parallel seems to ignore threadCount
> -----------------------------------------------------
>
>                 Key: SUREFIRE-1059
>                 URL: https://jira.codehaus.org/browse/SUREFIRE-1059
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.16
>            Reporter: Henryk Sarat
>
> I'm trying to run 6 tests in parallel in 2 threads. However, it seems like as 
> man threads launch at one time instead of just 2. My proof here is via the 
> Thread Id that I print out and because the test finishes in around 18seconds. 
> I expect the test to finish in about 38 seconds. I got to this number because 
> I have 6 methods that sleep for 10 seconds each. If 2 threads run in 
> parallel, then the total run time should be 6methods/2threads = 30 seconds 
> (there there is about 8 seconds of build time of everything else). Am I doing 
> something wrong? Or has an update over the years broke this in some way?
> POM File:
> {code}
>    <build>
>         <resources>
>             <resource>
>                 <directory>src/main/resources</directory>
>                 <filtering>true</filtering>
>             </resource>
>         </resources>
>         <plugins>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-surefire-plugin</artifactId>
>                 <version>2.16</version>
>                 <configuration>
>                     <parallel>methods</parallel>
>                     <threadCount>2</threadCount>
>                     <forkCount>2</forkCount>
>                 </configuration>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <version>2.3.2</version>
>                 <configuration>
>                     <source>${java.version}</source>
>                     <target>${java.version}</target>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </build>
> {code}
> JUnit:
> {code}
>         <dependency>
>           <groupId>junit</groupId>
>           <artifactId>junit</artifactId>
>           <version>4.11</version>
>         </dependency>
> {code}
> Java test class:
> {code}
> public class FourthTest {
>     @Test
>     public void testOne() throws InterruptedException, ExecutionException, 
> IOException {
>         for(int i =0;i<10;i++) {
>             Thread.sleep(1000);
>             System.out.println("one --- " + Thread.currentThread().getId());
>         }
>     }
>     @Test
>     public void testTwo() throws InterruptedException, ExecutionException, 
> IOException {
>         for(int i =0;i<10;i++) {
>             Thread.sleep(1000);
>             System.out.println("two --- " + Thread.currentThread().getId());
>         }
>     }
>     @Test
>     public void testThree() throws InterruptedException, ExecutionException, 
> IOException {
>         for(int i =0;i<10;i++) {
>             Thread.sleep(1000);
>             System.out.println("three --- " + Thread.currentThread().getId());
>         }
>     }
>     @Test
>     public void testFour() throws InterruptedException, ExecutionException, 
> IOException {
>         for(int i =0;i<10;i++) {
>             Thread.sleep(1000);
>             System.out.println("four --- " + Thread.currentThread().getId());
>         }
>     }
>     @Test
>     public void testFive() throws InterruptedException, ExecutionException, 
> IOException {
>         for(int i =0;i<10;i++) {
>             Thread.sleep(1000);
>             System.out.println("five --- " + Thread.currentThread().getId());
>         }
>     }
>                                                                            
> volatile static boolean a = false;
>     @Test
>     public void testSix() throws InterruptedException, ExecutionException, 
> IOException {
>         for(int i =0;i<10;i++) {
>             Thread.sleep(1000);
>             System.out.println("six --- " + Thread.currentThread().getId());
>             //if (!a){(new Exception()).printStackTrace(System.out);a=true;}
>     }
>     }
> }
> {code}
> command line: 
> {code}
> mvn clean install test -Dtest=FourthTest -T 2
> {code}
> Output
> {code}
> [INFO] Scanning for projects...
> [INFO] Building with 2 threads
> [INFO]
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Building mobile 1.0-SNAPSHOT
> [INFO] 
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ mobile ---
> [INFO] Deleting 
> [INFO]
> [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ 
> mobile ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. 
> build is platform dependent!
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory 
> [INFO]
> [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mobile ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. 
> build is platform dependent!
> [INFO] Compiling 51 source files to 
> [INFO]
> [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) 
> @ mobile ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
> resources, i.e. build is platform dependent!
> [INFO] Copying 2 resources
> [INFO]
> [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ 
> mobile ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. 
> build is platform dependent!
> [INFO] Compiling 23 source files to 
> [INFO]
> [INFO] --- maven-surefire-plugin:2.16:test (default-test) @ mobile ---
> [INFO] Surefire report directory: 
> [INFO] parallel='methods', perCoreThreadCount=true, threadCount=2, 
> useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, 
> threadCountMethods=0
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running com.blah.ios.FourthTest
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> three --- 11
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> six --- 9
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> four --- 13
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> one --- 8
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> five --- 12
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> two --- 10
> Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 60.101 sec - 
> in com.blah.ios.FourthTest
> Results :
> Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
> [INFO]
> [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ mobile ---
> [INFO] Building jar: 
> /Users/XX/Documents/XXXXXX/XXXX/XXX/target/mobile-1.0-SNAPSHOT.jar
> [INFO]
> [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ mobile ---
> [INFO] Installing 
> /Users/XX/Documents/bboxprojects/XXXXXXX/XXXX/target/mobile-1.0-SNAPSHOT.jar 
> to 
> /Users/XXXXXX/.m2/repository/com/XXXXX/automation/XXXXX/1.0-SNAPSHOT/mobile-1.0-SNAPSHOT.jar
> [INFO] Installing /Users/XXXXXX/Documents/XXXXX/XXXX/mobile/pom.xml to 
> /Users/XXXXX/.m2/repository/com/XXXXX/XXXX/mobile/1.0-SNAPSHOT/mobile-1.0-SNAPSHOT.pom
> [INFO]
> [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ 
> mobile ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. 
> build is platform dependent!
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory 
> /Users/XXXXXX/Documents/XXXXX/XXXX/XXXXX/src/main/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mobile ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. 
> build is platform dependent!
> [INFO] Compiling 1 source file to 
> /Users/XXXXX/Documents/XXXX/XXXX/XXX/target/classes
> [INFO]
> [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) 
> @ mobile ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
> resources, i.e. build is platform dependent!
> [INFO] Copying 2 resources
> [INFO]
> [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ 
> mobile ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-surefire-plugin:2.16:test (default-test) @ mobile ---
> [INFO] Skipping execution of surefire because it has already been run for 
> this configuration
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Total time: 18.363s (Wall Clock)
> [INFO] Finished at: Wed Feb 05 15:44:25 PST 2014
> [INFO] Final Memory: 29M/122M
> [INFO] 
> ------------------------------------------------------------------------
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to