コード例 #1
0
 @Test
 public void shouldAcceptCommaSeparatedListOfAdditionalClassPathElements() {
   final ReportOptions ro = parseAddingRequiredArgs("--classPath", "/foo/bar,./boo");
   final Collection<String> actual = ro.getClassPathElements();
   assertTrue(actual.contains("/foo/bar"));
   assertTrue(actual.contains("./boo"));
 }
コード例 #2
0
 @Test
 public void shouldDefaultMutationUnitSizeToCorrectValue() {
   final ReportOptions actual = parseAddingRequiredArgs("");
   assertEquals(
       (int) ConfigOption.MUTATION_UNIT_SIZE.getDefault(Integer.class),
       actual.getMutationUnitSize());
 }
コード例 #3
0
 @Test
 public void shouldUseTargetClassesFilterForTestsWhenNoTargetTestsFilterSupplied() {
   final ReportOptions actual = parseAddingRequiredArgs("--targetClasses", "foo*,bar*");
   final Predicate<String> actualPredicate = actual.getTargetTestsFilter();
   assertTrue(actualPredicate.apply("foo_anything"));
   assertTrue(actualPredicate.apply("bar_anything"));
   assertFalse(actualPredicate.apply("notfoobar"));
 }
コード例 #4
0
 @Test
 public void shouldCreatePredicateFromCommaSeparatedListOfTargetClassGlobs() {
   final ReportOptions actual = parseAddingRequiredArgs("--targetClasses", "foo*,bar*");
   final Predicate<String> actualPredicate = actual.getTargetClassesFilter();
   assertTrue(actualPredicate.apply("foo_anything"));
   assertTrue(actualPredicate.apply("bar_anything"));
   assertFalse(actualPredicate.apply("notfoobar"));
 }
コード例 #5
0
 @Test
 public void shouldParseCommaSeparatedListOfExcludedMethods() {
   final ReportOptions actual = parseAddingRequiredArgs("--excludedMethods", "foo*,bar*,car");
   final Predicate<String> actualPredicate = Prelude.or(actual.getExcludedMethods());
   assertTrue(actualPredicate.apply("foox"));
   assertTrue(actualPredicate.apply("barx"));
   assertTrue(actualPredicate.apply("car"));
   assertFalse(actualPredicate.apply("carx"));
 }
コード例 #6
0
  private void setTestType(final ReportOptions data) {
    final TestGroupConfig conf =
        new TestGroupConfig(this.mojo.getExcludedGroups(), this.mojo.getIncludedGroups());
    final ConfigurationFactory configFactory =
        new ConfigurationFactory(conf, new ClassPathByteArraySource(data.getClassPath()));

    data.setGroupConfig(conf);
    data.setConfiguration(configFactory.createConfiguration());
  }
コード例 #7
0
 @Test
 public void shouldParseCommaSeparatedListOfExcludedClassGlobsAndApplyTheseToTests() {
   final ReportOptions actual =
       parseAddingRequiredArgs(
           "--excludedClasses",
           "foo*",
           "--targetTests",
           "foo*,bar*",
           "--targetClasses",
           "foo*,bar*");
   final Predicate<String> testPredicate = actual.getTargetTestsFilter();
   assertFalse(testPredicate.apply("foo_anything"));
   assertTrue(testPredicate.apply("bar_anything"));
 }
コード例 #8
0
 @Test
 public void shouldParseCommaSeparatedListOfMutationOperators() {
   final ReportOptions actual =
       parseAddingRequiredArgs(
           "--mutators",
           ConditionalsBoundaryMutator.CONDITIONALS_BOUNDARY_MUTATOR.name()
               + ","
               + MathMutator.MATH_MUTATOR.name());
   assertEquals(
       Arrays.asList(
           ConditionalsBoundaryMutator.CONDITIONALS_BOUNDARY_MUTATOR.name(),
           MathMutator.MATH_MUTATOR.name()),
       actual.getMutators());
 }
コード例 #9
0
 @Test
 public void shouldHandleNotCanonicalLaunchClasspathElements() {
   final String oldClasspath = System.getProperty(JAVA_CLASS_PATH_PROPERTY);
   try {
     // given
     final PluginServices plugins = PluginServices.makeForContextLoader();
     this.testee = new OptionsParser(new PluginFilter(plugins));
     // and
     System.setProperty(JAVA_CLASS_PATH_PROPERTY, getNonCanonicalGregorEngineClassPath());
     // when
     final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=false");
     // then
     assertThat(actual.getClassPath().findClasses(gregorClass())).hasSize(1);
   } finally {
     System.setProperty(JAVA_CLASS_PATH_PROPERTY, oldClasspath);
   }
 }
コード例 #10
0
 @Test
 public void shouldNotIncludeLaunchClasspathWhenFlagUnset() {
   final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=false");
   assertFalse(actual.isIncludeLaunchClasspath());
 }
コード例 #11
0
 @Test
 public void shouldIncludeLaunchClasspathWhenFlag() {
   final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=true");
   assertTrue(actual.isIncludeLaunchClasspath());
 }
コード例 #12
0
 @Test
 public void shouldParseMutationUnitSize() {
   final ReportOptions actual = parseAddingRequiredArgs("--mutationUnitSize", "50");
   assertEquals(50, actual.getMutationUnitSize());
 }
コード例 #13
0
 @Test
 public void shouldIncludeLaunchClasspathByDefault() {
   final ReportOptions actual = parseAddingRequiredArgs("");
   assertTrue(actual.isIncludeLaunchClasspath());
 }
コード例 #14
0
 @Test
 public void shouldParseCommaSeparatedListOfSourceDirectories() {
   final ReportOptions actual = parseAddingRequiredArgs("--sourceDirs", "foo/bar,bar/far");
   assertEquals(Arrays.asList(new File("foo/bar"), new File("bar/far")), actual.getSourceDirs());
 }
コード例 #15
0
 @Test
 public void shouldParseCommaSeparatedListOfJVMArgs() {
   final ReportOptions actual = parseAddingRequiredArgs("--jvmArgs", "foo,bar");
   assertEquals(Arrays.asList("foo", "bar"), actual.getJvmArgs());
 }
コード例 #16
0
 @Test
 public void shouldDefaultToHtmlReportWhenNoOutputFormatsSpecified() {
   final ReportOptions actual = parseAddingRequiredArgs();
   assertEquals(new HashSet<String>(Arrays.asList("HTML")), actual.getOutputFormats());
 }
コード例 #17
0
 @Test
 public void shouldDefaultJVMToNull() {
   final ReportOptions actual = parseAddingRequiredArgs();
   assertEquals(null, actual.getJavaExecutable());
 }
コード例 #18
0
 @Test
 public void shouldParseCoverageThreshold() {
   final ReportOptions actual = parseAddingRequiredArgs("--coverageThreshold", "42");
   assertEquals(42, actual.getCoverageThreshold());
 }
コード例 #19
0
 @Test
 public void shouldDefaultToGregorEngineWhenNoOptionSupplied() {
   final ReportOptions actual = parseAddingRequiredArgs();
   assertEquals("gregor", actual.getMutationEngine());
 }
コード例 #20
0
 @Test
 public void shouldParseHistoryOutputLocation() {
   final ReportOptions actual = parseAddingRequiredArgs("--historyOutputLocation", "foo");
   assertEquals(new File("foo"), actual.getHistoryOutputLocation());
 }
コード例 #21
0
 @Test
 public void shouldDefaultToNoHistory() {
   final ReportOptions actual = parseAddingRequiredArgs("");
   assertNull(actual.getHistoryInputLocation());
   assertNull(actual.getHistoryOutputLocation());
 }
コード例 #22
0
 @Test
 public void shouldParseCommaSeparatedListOfOutputFormatsWhenSupplied() {
   final ReportOptions actual = parseAddingRequiredArgs("--outputFormats", "HTML,CSV");
   assertEquals(new HashSet<String>(Arrays.asList("HTML", "CSV")), actual.getOutputFormats());
 }
コード例 #23
0
 @Test
 public void shouldParseReportDir() {
   final String value = "foo";
   final ReportOptions actual = parseAddingRequiredArgs("--reportDir", value);
   assertEquals(value, actual.getReportDir());
 }
コード例 #24
0
 @Test
 public void shouldParseJVM() {
   final ReportOptions actual = parseAddingRequiredArgs("--jvmPath", "foo");
   assertEquals("foo", actual.getJavaExecutable());
 }
コード例 #25
0
 @Test
 public void shouldParseVerboseFlag() {
   final ReportOptions actual = parseAddingRequiredArgs("--verbose");
   assertTrue(actual.isVerbose());
 }
コード例 #26
0
 @Test
 public void shouldParseExportLineCoverageFlag() {
   final ReportOptions actual = parseAddingRequiredArgs("--exportLineCoverage");
   assertTrue(actual.shouldExportLineCoverage());
 }
コード例 #27
0
 @Test
 public void shouldParseMaxDepenencyDistance() {
   final ReportOptions actual = parseAddingRequiredArgs("--dependencyDistance", "42");
   assertEquals(42, actual.getDependencyAnalysisMaxDistance());
 }
コード例 #28
0
 @Test
 public void shouldNotExportLineCoverageWhenFlagNotSet() {
   final ReportOptions actual = parseAddingRequiredArgs("");
   assertFalse(actual.shouldExportLineCoverage());
 }
コード例 #29
0
 @Test
 public void shouldParseMutationEnigne() {
   final ReportOptions actual = parseAddingRequiredArgs("--mutationEngine", "foo");
   assertEquals("foo", actual.getMutationEngine());
 }
コード例 #30
0
 @Test
 public void shouldParseCommaSeparatedListOfIncludedTestGroups() {
   final ReportOptions actual = parseAddingRequiredArgs("--includedGroups", "foo,bar");
   assertEquals(Arrays.asList("foo", "bar"), actual.getGroupConfig().getIncludedGroups());
 }