Saturday, August 4, 2012

Testing an ant Task

I had to test the SchemaCrawler ant task. Some research shows

  1. Include the ant testunit jar - in a Maven project you can add a dependency such as

  1. Extend your test case from
  2. Write a setup like
  public void setUp()
    throws Exception
    configureProject( "./build.xml" );
  1. Write your test cases, with the methods starting with "test" (as in the classic JUnit)
  public void testAntTask()
    throws Exception
    final File testOutputFile = File.createTempFile("schemacrawler.",
    setAntProjectProperty("outputfile", testOutputFile.getAbsolutePath());

    // some asserts here

  1. You can set properties with the utility method
  private void setAntProjectProperty(final String name, final String value)
    final Project antProject = getProject();
    antProject.setProperty(name, value);

No comments:

Post a Comment