1.

Is it possible to test the Java method for a timeout in JUnit?

Answer»

Yes, it is possible. @Test annotation provides a timeout parameter that takes value in MILLISECONDS in JUNIT that is USED for INSTRUCTING JUnit to pass or fail the test method based on execution time. For instance, if a test method has Test annotation as @Test(timeout=30), then it means that if the execution does not COMPLETE in 30ms, then the test case will be failed. This helps in verifying the SLA of the Java method.



Discussion

No Comment Found