Search code examples
oraclemavenplsqlutplsql

How to cleanup the utplsql testpackages?


I wrote a few utPL/SQL Test on a PL/SQL Package, put them into a maven project and let them execute by jenkins. I wonder if there is a way to get rid of the test packages created in the database? It feels a bit weird that the test artefacts stay in the database.

I would either consider a maven goal within the utPL/SQL Plugin to delete the created test packages or having a seperate goal, where I can execute PL/SQL to drop the packages. I would also appreciate other ideas.


Solution

  • As proposed in the Question I found one solution using the sql maven plugin to execute a sql statement. Adding this, dropping the package is executed within the test goal but after the utplsql tests are executed.

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>sql-maven-plugin</artifactId>
    
      <executions>
        <execution>
          <id>default-cli</id>
          <phase>test</phase>
          <goals><goal>execute</goal></goals>
          <configuration>
            <sqlCommand>DROP PACKAGE UT_PACKAGENAMEUNDERTEST</sqlCommand>
          </configuration>                
        </execution>
      </executions>
    </plugin>
    

    In the configuration I left out the jdbc driver configuration. It is analogue to the configuration of the utplsql plugin. Or simple have a look at http://mojo.codehaus.org/sql-maven-plugin/usage.html