Project Testing: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 15: Line 15:
</properties>
</properties>


</pre>
Note that the below section must be declared under the <plugins> and not <pluginManagement>:
<pre>
...
...


<plugin>
<build>
    <groupId>org.apache.maven.plugins</groupId>
    <plugins>
    <artifactId>maven-antrun-plugin</artifactId>
        <plugin>
    <dependencies>
            <groupId>org.apache.maven.plugins</groupId>
        <dependency>
            <artifactId>maven-antrun-plugin</artifactId>
            <groupId>org.apache.ant</groupId>
            <dependencies>
            <artifactId>ant</artifactId>
                <dependency>
            <version>1.7.0</version>
                    <groupId>org.apache.ant</groupId>
        </dependency>
                    <artifactId>ant</artifactId>
    </dependencies>
                    <version>1.7.0</version>
    <executions>
                  </dependency>
        <execution>
              </dependencies>
            <phase>generate-test-resources</phase>
              <executions>
            <configuration>
                  <execution>
                <tasks>
                      <phase>generate-test-resources</phase>
                    <mkdir dir="${test.scratch.directory}" />
                              <configuration>
                </tasks>
                          <tasks>
            </configuration>
                              <mkdir dir="${test.scratch.directory}" />
            <goals>
                          </tasks>
                <goal>run</goal>
                      </configuration>
            </goals>
                      <goals>
        </execution>
                          <goal>run</goal>
    </executions>
                      </goals>
</plugin>
                </execution>
            </executions>
        </plugin>
    </plugins>
  ...
</build>


</pre>
</pre>

Revision as of 20:16, 28 June 2016

Internal

Testing Files in the Scratch Area of the Project

Maven Configuration


...

<properties>
    <test.scratch.directory>target/test-scratch</test.scratch.directory>
</properties>

Note that the below section must be declared under the <plugins> and not <pluginManagement>:

...

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <dependencies>
                 <dependency>
                     <groupId>org.apache.ant</groupId>
                     <artifactId>ant</artifactId>
                     <version>1.7.0</version>
                  </dependency>
              </dependencies>
              <executions>
                  <execution>
                      <phase>generate-test-resources</phase>
                               <configuration>
                          <tasks>
                              <mkdir dir="${test.scratch.directory}" />
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                 </execution>
             </executions>
         </plugin>
    </plugins>
   ...
</build>

Code

String projectBaseDirName = System.getProperty("basedir");
File testScratchDir = new File(projectBaseDirName, "target/scratch");
assertTrue(testScratchDir.isDirectory());

...