Skip to content

Commit

Permalink
Document test method execution order in Javadoc
Browse files Browse the repository at this point in the history
Issue: #13
  • Loading branch information
sbrannen committed Jan 4, 2019
1 parent 4f90161 commit bc417b4
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ or meta-annotated with `@Test`, `@RepeatedTest`, `@ParameterizedTest`, `@TestFac
Although true _unit tests_ typically should not rely on the order in which they are
executed, there are times when it is necessary to enforce a specific test method execution
order -- for example, when writing _integration tests_ or _functional tests_ where the
sequence of the tests is important, especially in conjunction
sequence of the tests is important, especially in conjunction with
`@TestInstance(Lifecycle.PER_CLASS)`.

To control the order in which test methods are executed, annotate your test class or test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@
* create a custom <em>composed annotation</em> that inherits the semantics
* of {@code @RepeatedTest}.
*
* <h3>Test Execution Order</h3>
*
* <p>By default, test methods will be ordered using an algorithm that is
* deterministic but intentionally nonobvious. This ensures that subsequent runs
* of a test suite execute test methods in the same order, thereby allowing for
* repeatable builds. In this context, a <em>test method</em> is any instance
* method that is directly annotated or meta-annotated with {@code @Test},
* {@code @RepeatedTest}, {@code @ParameterizedTest}, {@code @TestFactory}, or
* {@code @TestTemplate}.
*
* <p>Although true <em>unit tests</em> typically should not rely on the order
* in which they are executed, there are times when it is necessary to enforce
* a specific test method execution order &mdash; for example, when writing
* <em>integration tests</em> or <em>functional tests</em> where the sequence of
* the tests is important, especially in conjunction with
* {@link TestInstance @TestInstance(Lifecycle.PER_CLASS)}.
*
* <p>To control the order in which test methods are executed, annotate your
* test class or test interface with {@link TestMethodOrder @TestMethodOrder}
* and specify the desired {@link MethodOrderer} implementation.
*
* @since 5.0
* @see DisplayName
* @see RepetitionInfo
Expand Down
31 changes: 28 additions & 3 deletions junit-jupiter-api/src/main/java/org/junit/jupiter/api/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,36 @@
* resolved by {@link org.junit.jupiter.api.extension.ParameterResolver
* ParameterResolvers}.
*
* <p>{@code @Test} may also be used as a meta-annotation in order to
* create a custom <em>composed annotation</em> that inherits the semantics
* of {@code @Test}.
* <p>{@code @Test} may also be used as a meta-annotation in order to create
* a custom <em>composed annotation</em> that inherits the semantics of
* {@code @Test}.
*
* <h3>Test Execution Order</h3>
*
* <p>By default, test methods will be ordered using an algorithm that is
* deterministic but intentionally nonobvious. This ensures that subsequent runs
* of a test suite execute test methods in the same order, thereby allowing for
* repeatable builds. In this context, a <em>test method</em> is any instance
* method that is directly annotated or meta-annotated with {@code @Test},
* {@code @RepeatedTest}, {@code @ParameterizedTest}, {@code @TestFactory}, or
* {@code @TestTemplate}.
*
* <p>Although true <em>unit tests</em> typically should not rely on the order
* in which they are executed, there are times when it is necessary to enforce
* a specific test method execution order &mdash; for example, when writing
* <em>integration tests</em> or <em>functional tests</em> where the sequence of
* the tests is important, especially in conjunction with
* {@link TestInstance @TestInstance(Lifecycle.PER_CLASS)}.
*
* <p>To control the order in which test methods are executed, annotate your
* test class or test interface with {@link TestMethodOrder @TestMethodOrder}
* and specify the desired {@link MethodOrderer} implementation.
*
* @since 5.0
* @see RepeatedTest
* @see org.junit.jupiter.params.ParameterizedTest
* @see TestTemplate
* @see TestFactory
* @see TestInfo
* @see DisplayName
* @see Tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@
* resolved by {@link org.junit.jupiter.api.extension.ParameterResolver
* ParameterResolvers}.
*
* <h3>Test Execution Order</h3>
*
* <p>By default, test methods will be ordered using an algorithm that is
* deterministic but intentionally nonobvious. This ensures that subsequent runs
* of a test suite execute test methods in the same order, thereby allowing for
* repeatable builds. In this context, a <em>test method</em> is any instance
* method that is directly annotated or meta-annotated with {@code @Test},
* {@code @RepeatedTest}, {@code @ParameterizedTest}, {@code @TestFactory}, or
* {@code @TestTemplate}.
*
* <p>Although true <em>unit tests</em> typically should not rely on the order
* in which they are executed, there are times when it is necessary to enforce
* a specific test method execution order &mdash; for example, when writing
* <em>integration tests</em> or <em>functional tests</em> where the sequence of
* the tests is important, especially in conjunction with
* {@link TestInstance @TestInstance(Lifecycle.PER_CLASS)}.
*
* <p>To control the order in which test methods are executed, annotate your
* test class or test interface with {@link TestMethodOrder @TestMethodOrder}
* and specify the desired {@link MethodOrderer} implementation.
*
* @since 5.0
* @see Test
* @see DynamicNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@
* create a custom <em>composed annotation</em> that inherits the semantics
* of {@code @TestTemplate}.
*
* <h3>Test Execution Order</h3>
*
* <p>By default, test methods will be ordered using an algorithm that is
* deterministic but intentionally nonobvious. This ensures that subsequent runs
* of a test suite execute test methods in the same order, thereby allowing for
* repeatable builds. In this context, a <em>test method</em> is any instance
* method that is directly annotated or meta-annotated with {@code @Test},
* {@code @RepeatedTest}, {@code @ParameterizedTest}, {@code @TestFactory}, or
* {@code @TestTemplate}.
*
* <p>Although true <em>unit tests</em> typically should not rely on the order
* in which they are executed, there are times when it is necessary to enforce
* a specific test method execution order &mdash; for example, when writing
* <em>integration tests</em> or <em>functional tests</em> where the sequence of
* the tests is important, especially in conjunction with
* {@link TestInstance @TestInstance(Lifecycle.PER_CLASS)}.
*
* <p>To control the order in which test methods are executed, annotate your
* test class or test interface with {@link TestMethodOrder @TestMethodOrder}
* and specify the desired {@link MethodOrderer} implementation.
*
* @since 5.0
* @see Test
* @see org.junit.jupiter.api.extension.TestTemplateInvocationContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@
* to create a custom <em>composed annotation</em> that inherits the semantics
* of {@code @ParameterizedTest}.
*
* <h3>Test Execution Order</h3>
*
* <p>By default, test methods will be ordered using an algorithm that is
* deterministic but intentionally nonobvious. This ensures that subsequent runs
* of a test suite execute test methods in the same order, thereby allowing for
* repeatable builds. In this context, a <em>test method</em> is any instance
* method that is directly annotated or meta-annotated with {@code @Test},
* {@code @RepeatedTest}, {@code @ParameterizedTest}, {@code @TestFactory}, or
* {@code @TestTemplate}.
*
* <p>Although true <em>unit tests</em> typically should not rely on the order
* in which they are executed, there are times when it is necessary to enforce
* a specific test method execution order &mdash; for example, when writing
* <em>integration tests</em> or <em>functional tests</em> where the sequence of
* the tests is important, especially in conjunction with
* {@link org.junit.jupiter.api.TestInstance @TestInstance(Lifecycle.PER_CLASS)}.
*
* <p>To control the order in which test methods are executed, annotate your
* test class or test interface with
* {@link org.junit.jupiter.api.TestMethodOrder @TestMethodOrder} and specify
* the desired {@link org.junit.jupiter.api.MethodOrderer MethodOrderer}
* implementation.
*
* @since 5.0
* @see org.junit.jupiter.params.provider.Arguments
* @see org.junit.jupiter.params.provider.ArgumentsProvider
Expand Down

0 comments on commit bc417b4

Please sign in to comment.