Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Specifically, running the command above will result in the tests running in the
## Example with file

```
mvn test -Dtest=path_to_file -Dsurefire.runOrder=testorder -pl dubbo-rpc/dubbo-rpc-dubbo
mvn test -Dsurefire.includesFile=path_to_file -Dsurefire.runOrder=testorder -pl dubbo-rpc/dubbo-rpc-dubbo
```

By specifying ```-Dsurefire.runOrder=testorder``` Maven test will run the specifed tests in the order that they appear in the file ```path_to_file```. Note that the ```path_to_file``` should be an **absolute** path (e.g., ```/home/user/project/test-list```).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -2265,7 +2266,24 @@ private List<String> getIncludeList()
if ( isSpecificTestSpecified() )
{
includes = new ArrayList<>();
addAll( includes, split( getTest(), "," ) );

File file = new File( getTest() );

if ( file.exists() )
{
try
{
includes = Files.readAllLines( file.toPath( ), Charset.defaultCharset( ) );
}
catch ( IOException e )
{
e.printStackTrace();
}
}
else
{
addAll( includes, split( getTest(), "," ) );
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import org.apache.maven.surefire.api.testset.RunOrderParameters;
import org.apache.maven.surefire.api.testset.TestListResolver;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
Expand Down Expand Up @@ -120,10 +124,24 @@ public int compare( String o1, String o2 )
public TestListResolver getTestListResolver()
{
String orderParam = System.getProperty( "test" );
if ( orderParam == null )
if ( orderParam == null )
{
throw new IllegalStateException( "TestListResolver in RunOrderCalculator should be used only when "
+ "system property -Dtest is set and runOrder is testorder" );
String orderParamFile = System.getProperty( "surefire.includesFile" );
if ( orderParamFile == null )
{
throw new IllegalStateException( "TestListResolver in RunOrderCalculator should be used only when "
+ "system property -Dtest or -Dsurefire.includesFile is set and runOrder is testorder" );
}
try
{
return new TestListResolver(
Files.readAllLines( new File( System.getProperty( "surefire.includesFile" ) )
.toPath(), Charset.defaultCharset() ) );
}
catch ( IOException e )
{
e.printStackTrace();
}
}
return new TestListResolver( Arrays.asList( orderParam.split( "," ) ) );
}
Expand Down