title: How to write automated acceptance tests for a Maven project packaged as a WAR file?
body: <p>I've been given the source code for an existing Java application (let's call it "WebApp") that needs to be tested . It's deployed into Glassfish as a WAR file. This is customer code so would like to avoid modifying the WebApp POM if I can help it.</p>
  
  <p>So I'm creating a separate project (in Eclipse) to do the testing. The new project needs to call methods directly on various WebApp classes. I tried referencing the WAR file as a Maven Dependency but after doing this it doesn't show up in Maven Dependencies in Eclipse - see below:</p>
  
  <pre><code>WebApp
      src/main/java
      ...
      pom.xml
  
  WebAppTest
      src/main/test
          test.package.name
              webAppAcceptanceTestIT.java
      Maven Dependencies
          junit-4.6.jar
          mockito-all-1.9.5.jar
          &lt;&lt;&lt; No WebApp war/jars here &gt;&gt;&gt;
  </code></pre>
  
  <p>The dependency in WebAppTest's pom looks like:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;...&lt;/groupId&gt;
      &lt;artifactId&gt;webapp&lt;/artifactid&gt;
      &lt;version&gt;...&lt;/version&gt;
      &lt;type&gt;war&lt;/type&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Have tried <code>type=jar</code> and <code>scope=test</code> instead but neither of these is hitting the mark. Not sure if I'm missing something or going about this the wrong way? Should I maybe be using Maven Modules instead? Don't want to over-complicate things. Of course I can cheat and add WebApp to WebAppTest's build path but I want to get this right so it works when it deploys.</p>
  
  <p>One other q - should WebAppTest be packaged as a WAR or JAR? It will only contain tests that execute WebApp code and check results. Am I right in thinking it would still need to be deployed into Glassfish as a WAR file?</p>