Git Product home page Git Product logo

Comments (2)

DerGreco avatar DerGreco commented on June 7, 2024

Also, with atLeast(500).until(true) the following exception can be thrown, which makes no apparent sense reading the sentence literally. You await at least X until the condition is true, and if the condition is true, you await at least X, is what I would expect.

Note that during(500).until(true) doesn't exhibit the same behaviour, it works "properly" or "as expected" in the sense described above.

org.awaitility.core.ConditionTimeoutException: Condition was evaluated in 100 milliseconds which is earlier than expected minimum timeout 500 milliseconds at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:169) at org.awaitility.core.CallableCondition.await(CallableCondition.java:78) at org.awaitility.core.CallableCondition.await(CallableCondition.java:26) at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:939) at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:908)

from awaitility.

GChapel avatar GChapel commented on June 7, 2024

Hello,

About your first post, you can specify pollInterval to reach your needs :

@Test
public void differentPollIntervalTest() {

    List<Duration> pollIntervalDurationList =
        List.of(
            Duration.ofMillis(100), // i.e. default pollInterval
            Duration.ofMillis(1),   // Extremely fast ( /!\ cpu usage )
            Duration.ofMillis(1000) // Slow
            );

    for (Duration duration : pollIntervalDurationList) {
        long totalDuration = 0;
        for (int i = 0; i < 10; i++) {
        long start = System.currentTimeMillis();
        await().during(Duration.ofMillis(250)).pollInterval(duration).until(() -> true);
        totalDuration += (System.currentTimeMillis() - start);
        }

        System.out.println(
            String.format("pollInterval %s : %d ms avg", duration, totalDuration / 10));
    }
}

Here the result :

pollInterval PT0.1S : 439 ms avg
pollInterval PT0.001S : 255 ms avg
pollInterval PT1S : 2024 ms avg

You can also set pollDelay to delay the start of polls.

Regards,

from awaitility.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.