- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.6k
 
Closed
Description
We tried to use the new @Timeout annotation introduced in #1885 to enforce a global timeout. I put it on the base class that all our JUnit Jupiter integration tests extend from.
It works, but unfortunately without any kind of "DisableOnDebug" feature we cannot realistically use it. When debugging a test and stepping through with a debugger it will fail early with the timeout.
If adding a global "DisableOnDebug" is not being considered, I think it would be a small fix to org.junit.jupiter.engine.extension.TimeoutExtension itself.
Just need to add something like this (copied from JUnit 4's DisableOnDebug) to TimeoutExtension and not apply the timeout if isDebugging() is true.
private static boolean isDebugging() {
    List<String> inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
    Iterator<String> iterator = inputArguments.iterator();
    String argument;
    do {
        if (!iterator.hasNext()) {
            return false;
        }
        argument = iterator.next();
        if ("-Xdebug".equals(argument)) {
            return true;
        }
    } while (!argument.startsWith("-agentlib:jdwp"));
    return true;
}remal