[ 
https://issues.apache.org/jira/browse/SUREFIRE-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15054248#comment-15054248
 ] 

Andreas Gudian commented on SUREFIRE-1207:
------------------------------------------

That's a tricky one. The usual way for a provider (our term for the piece of 
code that binds surefire to the JUnit / TestNG API) would be to just hand the 
filtering information over to JUnit/TestNG.

But even if we'd start to re-implement their filter logic and inspect the 
test-classes in our plugin-process, we'd have to be careful not to trigger the 
class-initialization. There are test classes out there that do some heavy 
static initialization, and under no circumstances do we want to trigger that in 
our main process, if the the tests are to be executed in their own fork. So 
we'd have to use {{Class.forName( className, noInitialize, classloader )}} - 
and then be very careful what we do with the Class instance to not trigger the 
initialization. So that would be a risk.

Another alternative, but cumbersome, would be to not load the class but read 
the bytecode to inspect the annotations at class and method level. Kinda like 
it's done in springframework.

> A new JVM is forked even for tests not matching the "groups" tag when 
> "reuseForks" is false
> -------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-1207
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1207
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.18.1
>            Reporter: Michael Comerford
>
> When the "groups" tag is used with "resuseForks" as false, a new fork is 
> created for every test, not just the one in the group tag. The tests which 
> don't match the group aren't ran, but a fork is still created and destroyed 
> for every test, which is very inefficient.
> Example:
> {code:xml}
> <plugin>
>     <artifactId>maven-surefire-plugin</artifactId>
>     <configuration>
>         <skip>true</skip>
>     </configuration>
>     <executions>
>         <execution>
>             <id>default-tests</id>
>             <phase>test</phase>
>             <goals>
>                 <goal>test</goal>
>             </goals>
>             <configuration>
>                 <skip>false</skip>
>                 <excludedGroups>IsolatedTests</excludedGroups>
>             </configuration>
>         </execution>
>         <execution>
>             <id>isolatedTests</id>
>             <phase>test</phase>
>             <goals>
>                 <goal>test</goal>
>             </goals>
>             <configuration>
>                 <skip>false</skip>
>                 <groups>IsolatedTests</groups>
>                 <forkCount>1</forkCount>
>                 <reuseForks>false</reuseForks>
>             </configuration>
>         </execution>
>     </executions>
> </plugin>
> {code}
> The forking can be seen when running maven in debug mode: {{mvn test -X}} and 
> searching for the text "Forking command line"



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to