开发者

Creating ANT script to deploy to glassfish, run junit tests and then un-deploy

Hey guys, I have a j2ee app which I am building with Netbeans. My task is to modify the build.xml so that after the app builds, ANT deploys开发者_StackOverflow the app to a server, runs Junit tasks on the app, and then un-deploys the app. So far I have the deploy and un-deploy working but I'm running into some trouble running the junit tasks.

I have a client project in Netbeans where my junit tasks lie. My trouble is that when this project is built, it doesn't compile my junit tests into the .jar. This causes problems when I run my ant junit tasks and ANT cannot find the appropriate .class files for the junit tests.

In the Netbeans Project Properties it allows me to set "Source Package Folders" and "Test Package Folders". If I add the "test" folder into the "Source Package Folders" and build the project it compiles the tests and includes them with the jar. This works, however it prevents me from running my junit tests as tests in netbeans which slows development.

Has anyone had any experience with solving such a problem? There may be a simple solution I am overlooking so if anyone has a word of advice I would appreciate it. Thanks in advance.

-Brad


If I understand what you're asking,

You shouldn't need to compile the test classes into the jar. Just compile them into some directory, say 'classes'. Then just include this directory in the fileset nested element for the junit task.

A simple example,

<target name="junit">
  <junit printsummary="true">
    <classpath>
      <pathelement location="${classes.dir}"/>
    </classpath>

    <test name="test.class.TestClass"/>
  </junit>
</target>


Had to point my junit task to the correct classpath. Was pointing to the exact directory of the .class files(project1/classes/com/blah/blah2/blah3) which is incorrect. Set classpath to project1/classes and it worked. Noob mistake.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜