java - JUnit with Ant returns "No runnable methods" -
i'm banging head against wall - have empty test file (its more test build file else
a few months build file got corrupted - , reason starting new project didnt fix it, had make 1 scratch, needed support build, requires test - , not working :(
package com.rcdc.questiondatabase; import org.junit.after; import org.junit.afterclass; import org.junit.before; import org.junit.beforeclass; import org.junit.test; import static org.junit.assert.*; public class rcdcservicetest { public rcdcservicetest() { } @beforeclass public static void setupclass() { } @afterclass public static void teardownclass() { } @before public void setup() { } @after public void teardown() { } // todo add test methods here. // methods must annotated annotation @test. example: // @test public void testhellotest() { if(true){ asserttrue(true); } } }
my build file:
<?xml version="1.0" encoding="utf-8"?> <project name="incap" default="default" basedir="."> <description>builds, tests, , runs project incap.</description> <property name="build.dir" value="war/web-inf/classes"/> <property name="dist.dir" value="dist"/> <property name="test.dir" value="test"/> <property name="test.build.dir" value="testbuild"/> <path id="project.classpath"> <pathelement path="war/web-inf/classes" /> <fileset dir="war/web-inf/lib"> <include name="**/*.jar" /> </fileset> <pathelement path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/> </path> <path id="project.test.classpath"> <pathelement path="war/web-inf/classes" /> <fileset dir="war/web-inf/lib"> <include name="**/*.jar" /> </fileset> <pathelement path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/> </path> <target name="copyjars" description="copies app engine jars war."> </target> <target name="clean"> <delete dir="war/web-inf/classes"/> </target> <target name="compile" depends="copyjars" description="compiles java source , copies other source files war."> <mkdir dir="${build.dir}" /> <copy todir="${build.dir}"> <fileset dir="src"> <exclude name="**/*.java" /> </fileset> </copy> <property name="myclasspath" refid="project.classpath"/> <echo message="classpath ${myclasspath}" /> <javac srcdir="src" destdir="${build.dir}" classpathref="project.classpath" debug="on" /> </target> <target name="compiletest" depends="compile" description="compile tests " > <mkdir dir="${test.build.dir}" /> <javac srcdir="test" destdir="${test.build.dir}" classpathref="project.test.classpath" debug="on" /> </target> <target name="dist" depends="compile"> <mkdir dir="war/web-inf/classes" /> <copy todir="war/web-inf/classes"> <fileset dir="src"> <exclude name="**/*.java" /> </fileset> </copy> <property name="myclasspath" refid="project.classpath"/> </target> <target name="test" depends="compiletest" description="run tests " > <junit printsummary="yes" fork="yes" haltonfailure="yes"> <formatter type="plain"/> <batchtest fork="true"> <fileset dir="${test.dir}"> <include name="**/*test*.java"/> </fileset> </batchtest> <classpath refid="project.test.classpath" /> </junit> </target> <target name="test-single" depends="compiletest" description="run single test"> <fail unless="browser.context" message="property not set: 'test-class'"/> <echo message=" -- running single test --"/> <echo message=" -- ${browser.context} --" /> <junit printsummary="yes" fork="yes" showoutput="yes" haltonfailure="yes"> <formatter type="plain"/> <batchtest fork="true"> <fileset dir="test"> <include name="${javac.includes}"/> </fileset> </batchtest> <classpath refid="project.classpath" /> </junit> </target> </project>
your test classpath doesn't seem have test classes on it, although ant knows test names should run, junit can't find associated class run.
from follow-up comment - when netbeans executes tests directly, invokes it's own junit runner associated listeners - or results parsers - hook junit lifecycle know tests doing. when tell netbeans run ant task, doesn't know ant doing (it doesn't have sight of tasks within ant), doesn't know whether you're trying run junit task, or 1 of many other tasks within ant wouldn't make sense try , reports on, other in console.
Comments
Post a Comment