beam icon indicating copy to clipboard operation
beam copied to clipboard

Find a way to set a default global per-test timeout for Java Java unit tests

Open damccorm opened this issue 2 years ago • 3 comments

Apparently java unit tests don't have timeouts. And as far as I can tell, Junit lets you set timeouts for individual tests and test classes, but provides no easy way to set a global timeout across multiple classes.

Imported from Jira BEAM-13523. Original Jira may contain additional context. Reported by: ibzib.

damccorm avatar Jun 04 '22 23:06 damccorm

Hello @damccorm , I started looking at this issue. After reading more about this, a way to implement a global timeouts for the unit tests is to create a base test class and specify a Timeout rule in it, then make all the test classes inherit the base test class, this will make all the test cases timeout if they cross the threshold without having to specify @Timeout annotation over each test method. Is this an acceptable solution?

gpt3ch avatar Jun 05 '22 17:06 gpt3ch

Hey @gpt3ch! That definitely seems reasonable to me, but I also don't have a ton of context on the Java test suites (I just migrated the issue to GitHub, this was originally reported by @ibzib).

Tagging a few folks who might have more context here in case they have thoughts: @ibzib, @klk, @kileys, or @y1chi

damccorm avatar Jun 05 '22 19:06 damccorm

Hello @damccorm, 'Global declarative Timeout' feature is implemented in Junit from Junit 5.5 version where we can set the global timeout for all the TCs. Documentation : https://junit.org/junit5/docs/5.5.0/user-guide/index.html#writing-tests-declarative-timeouts (section 2.19.2. Default Timeouts)

sulthan309 avatar Apr 27 '24 17:04 sulthan309