Skip to content

Provide mechanism to order the sequence of tests #13

Closed

Description

Overview

Although it is typically discouraged, having a way to order tests is useful to some people. The JUnit 4 @FixMethodOrder annotation specifically and deliberately makes it impossible to implement a simple ordering scheme, forcing users who want/need this to resort to method names like test245_ensureReasonableTestName().

Proposal

  • The minimal "requirement" would be to allow users to write their own MethodSorter for @FixMethodOrder
  • A reasonable implementation would be to allow @FixMethodOrder(ORDERED), and then @Order(integer) to specify individual tests. Tests could be run from smallest number to highest, with non-annotated methods having a default of 0. Methods with the same order could be run in parallel; different order tiers could not.

Related Issues

Deliverables

  • Introduce a mechanism for ordering testable methods within JUnit Jupiter.
  • Validate collection of methods ordered by an extension; log warning or error if methods were added or removed.
  • Introduce built-in support for alphanumeric ordering.
  • Introduce built-in support for @Order based ordering.
  • Introduce built-in support for random ordering.
  • Introduce Configuration Parameter for setting the seed used in random ordering.
  • Test ordering support in top-level classes.
  • Test ordering of @Test, @TestFactory and @TestTemplate methods.
  • Test ordering support in @Nested classes.
  • Test ordering support in conjunction with parallel test execution.
  • Extract junit.jupiter.execution.order.random.seed constant and document it.
  • Write Javadoc for all new types.
  • Update @API declarations for types with changed visibility, etc.
  • Document new features in User Guide.
  • Document new features in Release Notes.

Out of Scope

  • ❌ Consider introducing a mechanism for ordering tests with the JUnit Platform -- potentially at a later date in conjunction with a separate dedicated issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions