Hi,
  
    Your best bet is to debug it with Eclipse but NOT using the Eclipse
junit tool.
Change the ant junit target, add these jvmargs to the junit target
<junit ...>
<!-- To be added -->
<jvmarg value="-Xdebug" />
<jvmarg value="-Xnoagent" />
<jvmarg value="-Djava.compiler=NONE" />
<jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y" />
</junit>

Here I am using 8787 port for debugging which should be a free port on your
machine.

When the ant reaches this task, it will wait (because suspend=y), now from
Eclipse, launch a "Remote Java Application" debug with Connection Properties
set as localhost and 8787. Set breakpoints wherever required.

Hope this helps!

Mikael Petterson (KI/EAB) wrote:
> 
> Hi,
> 
> I run a junit test ( junit 3.8.1 in both) in Eclipse it works just fine.
> Then I run the test in Ant using:
> 
> <target  name="test:test" depends="test:postcompile" description="run
> all tests">
>   <junit showoutput="yes" printsummary="on"  haltonfailure="no"
> fork="on" failureproperty="junit_test_failed" forkmode="perBatch">
>     <jvmarg value="-Xmx756M" />
>     <jvmarg
> value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" /> 
>     <jvmarg value="-Demma.coverage.out.merge=true" /> 
>     <classpath>
>      <pathelement location="${out.instr.dir}"/>
>      <pathelement location="${test.classes.dir}"/>
>      <pathelement location="${classes.dir}"/>
>      <path refid="test.classpath"/>
>      <path refid="emma.lib" />
>    </classpath>
>    <!--<formatter type="brief" usefile="true"/>-->
>    <formatter type="xml" usefile="true"/>
>     <batchtest todir="${coverage.dir}">
>      <fileset dir="${test.classes.dir}">
>       <!--<include name="**/TestItAllCreate*"/>-->
>       <!--<include name="**/TestRecover*"/>-->
>       <include name="**/TestItAll.class"/>
>       <exclude name="**/alarm/tb/sut/*Test.class"/>
>       <include name="**/sut/*Test.class"/>
>       <exclude name="**/mock/**"/>
>      </fileset>
>     </batchtest>
>    </junit>
>    </target>
> 
> The test fails with an NullPointerException.
> 
> How are junit tests executed in ant?
> 
> Anyone knows if the jvm is restarted per suite or something. Since there
> must be differences in what objects are still in the environment.
> All ideas and hints are greatly appreciated!
> 
> Cheers,
> 
> //mikael
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Junit-test-fails-in-ant-but-not-in-Eclipse-tf3361400.html#a9479688
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to