beam
beam copied to clipboard
Find a way to set a default global per-test timeout for Java Java unit tests
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.
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?
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
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)