Skip to content

RepeatedFuncTest does not test multiple runs #375

Closed
@HDouss

Description

Despite of its purpose (and its name), the method runsFuncMultipleTimes in RepeatedFuncTest does not test if the function runs multiple times. Instead, it is testing if it is giving a different output in each call (in other words, if it is giving a random number each time).
Another way to look at the bug is that modifying the test such as not using RepeatedFunc at all, will succeed anyway.

    @Test
    public void runsFuncMultipleTimes() throws Exception {
        final Func<Boolean, Integer> func = (
            input -> {
                return new SecureRandom().nextInt();
            }
        );
        MatcherAssert.assertThat(
            func.apply(true),
            Matchers.not(Matchers.equalTo(func.apply(true)))
        );
    }

I expect the test to check if the "origin" function was actually executed as many times as wanted.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions