@Test
    public void testMissingTopicPartitionSelection() {
        String[] args = {
            "--bootstrap-server", "nohost:9092",
            "--election-type", "preferred"
        };
        assertEquals(1, LeaderElectionCommand.mainNoExit(args));
        String out = ToolsTestUtils.captureStandardErr(() -> LeaderElectionCommand.mainNoExit(args));
        assertTrue(out.startsWith("One and only one of the following options is required: "));
        assertTrue(out.contains(" all-topic-partitions"));
        assertTrue(out.contains(" topic"));
        assertTrue(out.contains(" path-to-json-file"));
    }
For some error cases, we can save a little build time by avoiding the overhead for
cluster creation and cleanup because the command is expected to fail immediately.
tools/src/test/java/org/apache/kafka/tools/LeaderElectionCommandErrorTest.java