private void assertInitializeInvalidOptionsExitCodeAndMsg(List<String> args, String expectedMsg) {
        Exit.setExitProcedure((exitCode, message) -> {
            assertEquals(1, exitCode);
            assertTrue(message.contains(expectedMsg));
            throw new RuntimeException();
        });
        try {
            assertThrows(RuntimeException.class, () -> new AclCommandOptions(args.toArray(new String[0])).checkArgs());
        } finally {
            Exit.resetExitProcedure();
        }
    }
Capture both the console output and console error during the execution of the provided function.
core/src/test/java/kafka/admin/AclCommandTest.java