-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finish reversealphabetical run order and test #5
base: tms-only-runorder
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ | |
|
||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
|
||
import org.apache.maven.surefire.api.testset.RunOrderParameters; | ||
|
||
|
@@ -59,4 +62,44 @@ static class B | |
{ | ||
|
||
} | ||
|
||
public void reverseAlphabeticalRunOrderTestClasses() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Names of these tests are invalid, They must start with "test" for JUnit 3 to find and run them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In your new branch, repurpose all reversealphabetical tests to become TESTORDER tests. |
||
{ | ||
getClassesToRun(); | ||
TestsToRun testsToRun = new TestsToRun( getClassesToRun() ); | ||
RunOrderParameters runOrderParameters = new RunOrderParameters( "reversealphabetical" , null ); | ||
RunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( runOrderParameters, 1 ); | ||
final TestsToRun testsToRun1 = runOrderCalculator.orderTestClasses( testsToRun ); | ||
assertEquals( B.class, testsToRun1.iterator().next() ); | ||
} | ||
|
||
public void reverseAlphabeticalRunOrderTestMethods() | ||
{ | ||
RunOrderParameters runOrderParameters = new RunOrderParameters( "reversealphabetical" , null ); | ||
RunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( runOrderParameters, 1 ); | ||
System.setProperty( "test", "org.apache.maven.surefire.api.util.RunOrderCalculatorTest$B#C,org.apache.maven.surefire.api.util.RunOrderCalculatorTest$B#D,org.apache.maven.surefire.api.util.RunOrderCalculatorTest$A#A,org.apache.maven.surefire.api.util.RunOrderCalculatorTest$A#B" ); | ||
Comparator<String> reverseAlphabeticalRunOrderComparator = runOrderCalculator.comparatorForTestMethods(); | ||
List<String> list = new ArrayList<String>(); | ||
list.add( "org.apache.maven.surefire.api.util.RunOrderCalculatorTest$B#A" ); | ||
list.add( "org.apache.maven.surefire.api.util.RunOrderCalculatorTest$B#B" ); | ||
list.add( "org.apache.maven.surefire.api.util.RunOrderCalculatorTest$A#C" ); | ||
list.add( "org.apache.maven.surefire.api.util.RunOrderCalculatorTest$A#D" ); | ||
list.sort( reverseAlphabeticalRunOrderComparator ); | ||
assertEquals( list.get(0), "org.apache.maven.surefire.api.util.RunOrderCalculatorTest$B#B" ); | ||
} | ||
|
||
public void shouldThrowExceptionForNullTestMethod() | ||
{ | ||
RunOrderParameters runOrderParameters = new RunOrderParameters( "reversealphabetical" , null ); | ||
RunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( runOrderParameters, 1 ); | ||
System.clearProperty( "test" ); | ||
try | ||
{ | ||
runOrderCalculator.comparatorForTestMethods(); | ||
} | ||
catch ( IllegalStateException expected ) | ||
{ | ||
assertEquals( expected.getMessage(), "Please set system property -Dtest to use fixed order" ); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduce duplication of code before this if/else block. You can move this if/else block to be lower and then just check for RunOrder.TESTORDER vs. RunOrder.REVERSEALPHEBETICAL at the necessary location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All reversealphabetical changes should be kept in this branch and another branch and pull request should be created to not have any reverse alphabetical related changes but still have new tests for TESTORDER