Continuation of #22789 and relates to #22996 Suggested solution doesn't allow debug tests and use JSON output simultaneously.