Questions tagged [awaitility]

Awaitility is a Java testing library and DSL that allows you to express expectations of an asynchronous system in a concise and easy to read manner.

Testing asynchronous systems is hard. Not only does it require handling threads, timeouts and concurrency issues, but the intent of the test code can be obscured by all these details. Awaitility is a DSL that allows you to express expectations of an asynchronous system in a concise and easy to read manner. For example:

38 questions
1
vote
1 answer

Awaitility: how to perform post-actions if a condition failed?

In Awaitility, how can I perform a post-action if a condition I'm waiting for fails? For example, collecting additional information, do some logging, or throwing an exception? The only way I've found is to use a try-catch: try { …
Vitali Plagov
  • 722
  • 1
  • 12
  • 31
1
vote
1 answer

How can I get the remaining time in an Awaitility poll?

Using Awaitility 4.0.1, I put together the following poll that polls my server for data for 5 minutes, in intervals of 10 seconds, and runs perfectly fine: AtomicReference response = null; with().pollInterval(10, TimeUnit.SECONDS) …
Florian
  • 4,821
  • 2
  • 19
  • 44
1
vote
0 answers

How to make sure an asynchronous test doesn't interfere with another?

I would like to unit test the behavior of my function which uses an asynchronous call to external API (using WebClient, but I doubt it is relevant). A simplified version of the flow of the function would be this fun foo() { if (conditionIsMet) { …
Cyrille
  • 11
  • 2
1
vote
0 answers

Awaitility not working JAVA+APPIUM+CUCUMBER

I am currently facing a weird issue using java awaitility library. I am using awaitility to wait for a minute and check one condition using the below statement. String currentTime = getAvailableDriveTime(); await("Wait for time") .atMost(60,…
1
vote
1 answer

Wait x milliseconds or until a condition becomes true

I have a code where I send data to our queues and then queue send the acknowledgement back saying they have received the data so I wait for X amount of time before checking whether they have received the data or not. Below is the code which does…
flash
  • 1,455
  • 11
  • 61
  • 132
0
votes
1 answer

Testing Netty client server with Awaitility?

Has anyone tried to use Awaitility to test a Netty Client and Server. I want to test that the server has received all messages from the Client and any other tests that might be useful. I suppose the only thing is how to get the number of messages…
DarVar
  • 16,882
  • 29
  • 97
  • 146
0
votes
0 answers

TimeUnit.SECONDS.sleep(10) replace with await

When i use the TimeUnit.SECONDS.sleep(10) in below Junit, Sonar issue is coming, Is there any way to replace sleep with await in below Junit? String ccNotification = DMTestConstants.UPDATE_EVENTS; kafkaMessageProdce(props, ccNotification,…
ga7202
  • 93
  • 8
0
votes
1 answer

How to have meaningful awaitility failure?

I would like be able to receive meaningful errors, for example Set set = new HashSet(); await().until(() -> set.contains("foo")); // during waiting set.add("bar") // after timeout "Condition 'foo' should be in set=['bar'] not fulfilled I can…
michaldo
  • 4,195
  • 1
  • 39
  • 65
0
votes
0 answers

testing a @Scheduled task in spring-boot that requires mocking a static method

I am trying to validate a scheduled task in a spring-boot application. A static method is called in the flow. Using mockedStatic works as expected when the service class is tested standalone, but not when the service is called as part of the…
0
votes
1 answer

java.util.concurrent.TimeoutException executing parallels scenarios in Selenium Grid in Docker

Our Automation project is written in Java, and we are using the following libraries: Cucumber 3.1.6 Selenium 4.0.0 awaitility 3.1.6 We are executing several Jenkins jobs in parallel, in a Selenium Grid Docker version: 4.7.2 with a Hub and Chrome…
0
votes
1 answer

How to check if an event hasn't happened using awaitility

I'm trying to make sure that after some actions, no new records have appeared in the database, for this I use the following construction: messages = new String[] {"message1", "message2"}; await("wait") .during(Duration.ofSeconds(15)) …
0
votes
0 answers

Using Awaitility to verify a method wasn't called during duration

Is is possible to use awaitility to ensure a method wasn't called during the await? I have tried using @Test void testThatSomeMethodWasntCalled(){ await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> someClass.someMethod()) } But there doesn't…
0
votes
1 answer

Retrieving value from awaited task on Kotlin

C#/Java Dev trying to learn Kotlin here. I'm pinging a website from my Kotlin app, but I'm unable to fetch the awaited Task result. 'pingResponse' (inside the awaited function) returns true as expected. But 'pingResult' (part of the String Builder)…
0
votes
0 answers

Is this the correct waiting strategy when sending commands with testcontainers?

I am using Testcontainers DockerComposeContainer and sending shell commands using the execInContainer method once my containers are up and running: @ClassRule public static DockerComposeContainer environment = new…
0
votes
0 answers

Using Awaitility in Testfx FxRobot framework - wait is not happening till node visible

Using Awaitility in Testfx FxRobot framework - Unable to wait till node visible Everytime when fxid element is not shown on UI polling is not happening it is throwing node not found. Another thing is to save the captured snapshot path I am not…
Nee
  • 11
  • 3