forked from junit-team/junit4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Never reorder classes annotated with @FixMethodOrder
Fixes junit-team#1637
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.junit.runner; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.singletonList; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.FixMethodOrder; | ||
import org.junit.runners.model.TestClass; | ||
import org.junit.validator.AnnotationValidator; | ||
|
||
/** | ||
* Validates that there are no errors in the use of the {@code OrderWith} | ||
* annotation. If there is, a {@code Throwable} object will be added to the list | ||
* of errors. | ||
* | ||
* @since 4.13 | ||
*/ | ||
public final class OrderWithValidator extends AnnotationValidator { | ||
|
||
/** | ||
* Adds to {@code errors} a throwable for each problem detected. Looks for | ||
* {@code FixMethodOrder} annotations. | ||
* | ||
* @param testClass that is being validated | ||
* @return A list of exceptions detected | ||
* | ||
* @since 4.13 | ||
*/ | ||
@Override | ||
public List<Exception> validateAnnotatedClass(TestClass testClass) { | ||
if (testClass.getAnnotation(FixMethodOrder.class) != null) { | ||
return singletonList( | ||
new Exception("@FixMethodOrder cannot be combined with @OrderWith")); | ||
} | ||
return emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters