Add test which verifies that all commands have descriptions

Besides being good practice, this works around a bug in JCommander 1.48, which we are stuck with for now
since newer versions of the library are Java 8 only:
https://github.com/cbeust/jcommander/issues/270

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149565357
This commit is contained in:
shikhman 2017-03-08 11:53:05 -08:00 committed by Ben McIlwain
parent 01bb3a30f2
commit 9eddbe2b6e

View file

@ -19,6 +19,7 @@ import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.reflect.Reflection.getPackageName;
import static com.google.common.truth.Truth.assertThat;
import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.reflect.ClassPath;
@ -76,6 +77,16 @@ public class RegistryToolTest {
}
}
@Test
public void test_commandMap_allCommandsHaveDescriptions() throws Exception {
for (Map.Entry<String, ? extends Class<? extends Command>> commandEntry :
RegistryTool.COMMAND_MAP.entrySet()) {
Parameters parameters = commandEntry.getValue().getAnnotation(Parameters.class);
assertThat(parameters).isNotNull();
assertThat(parameters.commandDescription()).isNotEmpty();
}
}
/**
* Gets the set of all non-abstract classes implementing the {@link Command} interface (abstract
* class and interface subtypes of Command aren't expected to have cli commands). Note that this