Awaitility - a useful tool for unit/integration testing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Awaitility - a useful tool for unit/integration testing

Afkham Azeez-2
Hi team,
After looking into writing unit tests for a feature where I have to wait to see if the task hascompleted, I found a library called Awaitility (https://github.com/awaitility/), that is very elegant and suitable for the purpose. The error-prone way of achieving the same is using Thread.sleep.



It has a very beautiful and intuitive API where you can write code that looks like English sentences. For example.

await().atMost(5, SECONDS).until(() -> userRepository.size() == 1);


Check the usage guide for more details: https://github.com/awaitility/awaitility/wiki/Usage


Please take a look and adopt this library where applicable.

--
Afkham Azeez
Senior Director, Platform ArchitectureWSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/

email:
[hidden email] cell: +94 77 3320919
blog:
http://blog.afkham.org
twitter:
http://twitter.com/afkham_azeez
linked-in:
http://lk.linkedin.com/in/afkhamazeez

Lean . Enterprise . Middleware

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Awaitility - a useful tool for unit/integration testing

Irham Iqbal
Hi,

This might be useful for wait for deploying and un-deploying artifacts.

Thanks,
Iqbal 

On Tue, Oct 31, 2017 at 11:52 AM, Afkham Azeez <[hidden email]> wrote:
Hi team,
After looking into writing unit tests for a feature where I have to wait to see if the task hascompleted, I found a library called Awaitility (https://github.com/awaitility/), that is very elegant and suitable for the purpose. The error-prone way of achieving the same is using Thread.sleep.



It has a very beautiful and intuitive API where you can write code that looks like English sentences. For example.

await().atMost(5, SECONDS).until(() -> userRepository.size() == 1);


Check the usage guide for more details: https://github.com/awaitility/awaitility/wiki/Usage


Please take a look and adopt this library where applicable.

--
Afkham Azeez
Senior Director, Platform ArchitectureWSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/

email:
[hidden email] cell: <a href="tel:+94%2077%20332%200919" value="+94773320919" target="_blank">+94 77 3320919
blog:
http://blog.afkham.org
twitter:
http://twitter.com/afkham_azeez
linked-in:
http://lk.linkedin.com/in/afkhamazeez

Lean . Enterprise . Middleware

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Irham Iqbal
Software Engineer
WSO2


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev