Пример #1
0
  /** Test an invalid directory name, see if an error occurs */
  @Test
  public void testInvalidDirectory() {
    System.setSecurityManager(new NoExitSecurityManager());
    boolean exceptionThrown = false;

    cobertura = new Cobertura(null);
    try {
      cobertura.executeCobertura();
    } catch (ExitException e) {
      exceptionThrown = true;
      assertEquals(
          "Exit status invalid", OperiasStatus.ERROR_COBERTURA_TASK_CREATION.ordinal(), e.status);
    }

    exceptionThrown = false;

    cobertura = new Cobertura("src/../");
    try {
      cobertura.executeCobertura();
    } catch (ExitException e) {
      exceptionThrown = true;
      assertEquals(
          "Exit status invalid",
          OperiasStatus.ERROR_COBERTURA_TASK_OPERIAS_EXECUTION.ordinal(),
          e.status);
    }

    assertTrue("No exception was thrown", exceptionThrown);

    System.setSecurityManager(null);
  }
Пример #2
0
  /**
   * Proper execution of the maven project, but the coverage file was not found, can be test by
   * giving a random non existing output directory
   */
  @Test
  public void testCoverageXMLNotFound() {
    System.setSecurityManager(new NoExitSecurityManager());
    boolean exceptionThrown = false;

    cobertura = new Cobertura("src/test/resources/simpleMavenProject");
    cobertura.setOutputDirectory("target/randomFolder");
    try {
      cobertura.executeCobertura();
    } catch (ExitException e) {
      exceptionThrown = true;
      assertEquals("Exit status invalid", OperiasStatus.COVERAGE_XML_NOT_FOUND.ordinal(), e.status);
    }
    System.setSecurityManager(null);
    assertTrue("No exception was thrown", exceptionThrown);
  }