junit5 icon indicating copy to clipboard operation
junit5 copied to clipboard

Add Assumptions.assumeDoesNotThrow

Open ST-DDT opened this issue 5 years ago • 4 comments

I wish to skip some of my larger integration tests, if the target environment is not available/healthy.

For that I have to perform a http call. If the environment is not available/running/health, I get an exception. If it is healthy I get an OK-Health status with some additional metadata I slightly care about.

Currently I use the following construct for my assumption check.

try {
    List<String> services = cluster.listServices();
    assumeThat(services)
            .isNotEmpty()
            .contains(testServiceName);
    [...]
} catch (IncompleteExecutionException e) {
    throw e;
} catch (Exception e) {
    throw new TestAbortedException("Cluster not properly configured or not available", e);
}

I would like to be able to use the Assumptions here similar to the Assertions.assertDoesNotThrow(...).

List<String> services = assumeDoesNotThrow(cluster::listServices, "Cluster not properly configured or not available");
assumeThat(services)
        .isNotEmpty()
        .contains(testServiceName);

I'm willing to PR this feature, if it gets accepted.

ST-DDT avatar Nov 26 '20 13:11 ST-DDT

Tentatively slated for 5.8 M1 for team discussion

sbrannen avatar Nov 26 '20 14:11 sbrannen

Team decision: Your request sounds reasonable, but we're unsure how generally useful it is given it hasn't been requested before. Thus, changing the status to "waiting for interest".

marcphilipp avatar Nov 27 '20 11:11 marcphilipp

By the way, this has been requested before in https://github.com/junit-team/junit5/issues/1667 . I would also kindly support the request.

A248 avatar May 10 '21 21:05 A248

Hi @marcphilipp . May I please have a look into this issue? I'd like to try to enhance it.

HeaDHeaD0820 avatar Apr 23 '22 11:04 HeaDHeaD0820

Team decision: Given our limited capacity, the team has decided to close issues for which there has not been considerable interest.

marcphilipp avatar Apr 13 '23 14:04 marcphilipp