Skip to content

Introduce AroundEachCallback #1442

@mibutec

Description

@mibutec

Overview

I wonder if there was really no request for this, but I could find no issue.

With the existing extension APIs, it is possible but clumsy to implement functions like rerunning failing test or things like:

@Test
@ExpectedException(RuntimeException.class)
pulic void testException() {
  throw new RuntimeException();
}

Something like an AroundEachCallback would be quite helpful. Usage should be something like this:

public class RerunningExtension implements AroundEachCallback {
  @Override
  public void aroundTestMethod(Executable testIncludingBeforeAndAfter, ExtensionContext context) {
    while (cnt++ < getMaxNumberOfExecutions && failureExists) {
      try {
        failureExists = false;
        testIncludingBeforeAndAfter.execute();
      } catch (Exception e) {
        failureExists = true;
      }
    }
  }
}

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions