Last active
January 6, 2023 15:55
-
-
Save jordanrobinson/32a2e5951997c1139a2ce68afb5e13bb to your computer and use it in GitHub Desktop.
Awaitility blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn check-reactor-is-ready | |
[] | |
(let [counter (Math/random)] | |
(println (str "Reading is... " counter)) | |
(> counter 0.5))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await().until(checkReactorIsReady()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reading is... 0.14748365188970014 | |
Reading is... 0.39006578072452525 | |
Reading is... 0.11361210088909512 | |
Reading is... 0.3491163467675231 | |
Reading is... 0.7100413898618688 | |
Reading is... 0.4931516769505109 | |
Reading is... 0.9274004405826166 | |
Reading is... 0.776093982387096 | |
Reading is... 0.7668150587110371 | |
org.awaitility.core.ConditionTimeoutException: Condition foo$check_reactor_is_ready was not fulfilled within 1 seconds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:dependencies [ | |
... | |
[org.awaitility/awaitility "4.2.0"] | |
... | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(-> (Awaitility/await) | |
(.atMost 1 java.util.concurrent.TimeUnit/SECONDS) | |
(.until check-reactor-is-ready)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deftest something-happens | |
(.until (.atMost (Awaitility/await) 1 java.util.concurrent.TimeUnit/SECONDS) check-reactor-is-ready) | |
(testing "Does the reactor have all the right properties?" | |
(is (= "working" (reactor/condition))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example-test | |
(:require | |
[clojure.test :refer [is testing deftest]] | |
(:import | |
(org.awaitility | |
Awaitility)))) | |
(deftest something-happens | |
(.until (Awaitility/await) check-reactor-is-ready) | |
(testing "Does the reactor have all the right properties?" | |
(is (= "working" (reactor/condition))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment