From: David S. <ds...@us...> - 2007-02-21 20:26:34
|
Update of /cvsroot/junit/junit/src/org/junit/runner In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2290/src/org/junit/runner Modified Files: Request.java RunWith.java Log Message: Fixing exception handling and documentation Index: Request.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runner/Request.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Request.java 13 Dec 2006 02:10:50 -0000 1.2 +++ Request.java 21 Feb 2007 20:26:29 -0000 1.3 @@ -102,9 +102,27 @@ }); } + //TODO add an example /** * Returns a Request whose Tests can be run in a certain order, defined by * <code>comparator</code> + * + * For example, here is code to run a test suite in alphabetical order: + * + * <pre> + private static Comparator<Description> forward() { + return new Comparator<Description>() { + public int compare(Description o1, Description o2) { + return o1.getDisplayName().compareTo(o2.getDisplayName()); + } + }; + } + + public static main() { + new JUnitCore().run(Request.aClass(AllTests.class).sortWith(forward())); + } + * </pre> + * * @param comparator definition of the order of the tests in this Request * @return a Request with ordered Tests */ Index: RunWith.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runner/RunWith.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RunWith.java 21 Nov 2006 18:53:39 -0000 1.1 +++ RunWith.java 21 Feb 2007 20:26:29 -0000 1.2 @@ -6,7 +6,6 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -//TODO add simple example /** * When a class is annotated with <code>@RunWith</code> or extends a class annotated * with <code>@RunWith</code>, JUnit will invoke the class it references to run the @@ -14,6 +13,15 @@ * in development. While it seems powerful we expect the runner API to change as we learn * how people really use it. Some of the classes that are currently internal will likely * be refined and become public. + * + * For example, suites in JUnit 4 are built using RunWith, and a custom runner named Suite: + * + * <pre> + * @RunWith(Suite.class) + * @SuiteClasses(ATest.class, BTest.class, CTest.class) + * public class ABCSuite { + * } + * </pre> */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) |