Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ant build.xml for test project failing

User787232-OracleJan 25 2016 — edited Jan 27 2016

Hi,

I have simple search page, with testUI project for testing search(search.java) . From jdev,search.java runs without any error.

Test project and build.xml has equal number of jar references. Am i missing any jar?

While running the build.xml from jdev, junit fails

Targets clean, compile are working. But target 'Alltests' for fail with following error,

allTests:

     [echo] enter junit

     [echo] C:\mywork\UIsel\testUI\classes\tests

    [junit] Running search

    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

    [junit] Test search FAILED

Testsuite: search

Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

    Caused an ERROR

search (wrong name: tests/search)

java.lang.NoClassDefFoundError: search (wrong name: tests/search)

    at java.lang.ClassLoader.defineClass1(Native Method)

    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:630)

    at java.lang.ClassLoader.defineClass(ClassLoader.java:614)

    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)

    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:305)

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:246)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Class.java:169).

build.xml

<?xml version="1.0" encoding="windows-1252" ?>

<!--Ant buildfile generated by Oracle JDeveloper-->

<!--Generated 21 Jan, 2016 3:10:04 PM-->

<project name="testUI" default="all">

  <property file="build.properties"/>

  <path id="library.Junit4_4.3.1.jar">

    <pathelement location="C:/Downloads/junit4_4.3.1.jar/junit4_4.3.1.jar"/>

  </path>

  <path id="library.Selenium-java-client-driver.jar">

    <pathelement location="C:/Downloads/selenium-java-client-driver.jar/selenium-java-client-driver.jar"/>

  </path>

  <path id="library.Selenium-java-2.45.0.jar">

    <pathelement location="C:/Downloads/selenium-java-2.45.0/selenium-2.45.0/selenium-java-2.45.0.jar"/>

  

  </path>

  <path id="library.Selenium-server-standalone-2.45.0.jar">

    <pathelement location="c:/Users/s.yogesh/Downloads/selenium-server-standalone-2.45.0.jar"/>

  </path>

  <path id="classpath">

    <path refid="library.Junit4_4.3.1.jar"/>

    <path refid="library.Selenium-java-client-driver.jar"/>

    <path refid="library.Selenium-java-2.45.0.jar"/>

    <path refid="library.Selenium-server-standalone-2.45.0.jar"/>

    <!-- add to default build.xml to locate .adf\META-INF\connections.xml for DB connection-->

    <!--pathelement location="library.Junit4_4.3.1.jar"/-->

    <pathelement location="${uitest.name}"/>

  </path>

  <target name="init">

    <tstamp/>

    <mkdir dir="${output.dir}"/>

    <!-- create JUNIT dir-->

    <mkdir dir="${testresults.dir}"/>

  </target>

  <target name="all" description="Build the project"

          depends="compile,copy,allTests"/>

  <target name="clean" description="Clean the project">

    <delete includeemptydirs="true" quiet="true">

      <fileset dir="${output.dir}" includes="**/*"/>

      <fileset dir="${output.dir}" includes="**/*"/>

    </delete>

  </target>

  <target name="deploy" description="Deploy the project">

    <taskdef name="ojdeploy"

             classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask"

             uri="oraclelib:OJDeployAntTask"

             classpath="${oracle.jdeveloper.ant.library}"/>

    <ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask"

                  executable="${oracle.jdeveloper.ojdeploy.path}"

                  ora:buildscript="${oracle.jdeveloper.deploy.dir}/ojdeploy-build.xml"

                  ora:statuslog="${oracle.jdeveloper.deploy.dir}/ojdeploy-statuslog.xml">

      <ora:deploy>

        <ora:parameter name="workspace"

                       value="${oracle.jdeveloper.workspace.path}"/>

        <ora:parameter name="profile"

                       value="${oracle.jdeveloper.deploy.profile.name}"/>

        <ora:parameter name="nocompile" value="false"/>

        <ora:parameter name="outputfile"

                       value="${oracle.jdeveloper.deploy.outputfile}"/>

      </ora:deploy>

    </ora:ojdeploy>

  </target>

  <target name="compile" description="Compile Java source files" depends="init">

    <javac destdir="${output.dir}" classpathref="classpath"

           debug="${javac.debug}" nowarn="${javac.nowarn}"

           deprecation="${javac.deprecation}" encoding="Cp1252" source="1.6"

           target="1.6">

      <src path="src"/>

    </javac>

  </target>

  <target name="copy" description="Copy files to output directory"

          depends="init">

    <patternset id="copy.patterns">

      <include name="**/*.gif"/>

      <include name="**/*.jpg"/>

      <include name="**/*.jpeg"/>

      <include name="**/*.png"/>

      <include name="**/*.properties"/>

      <include name="**/*.xml"/>

      <include name="**/*.ejx"/>

      <include name="**/*.xcfg"/>

      <include name="**/*.cpx"/>

      <include name="**/*.dcx"/>

      <include name="**/*.sva"/>

      <include name="**/*.wsdl"/>

      <include name="**/*.ini"/>

      <include name="**/*.tld"/>

      <include name="**/*.tag"/>

      <include name="**/*.xlf"/>

      <include name="**/*.xsl"/>

      <include name="**/*.xsd"/>

      <include name="**/*.jpx"/>

    </patternset>

    <copy todir="${output.dir}">

      <fileset dir="src">

        <patternset refid="copy.patterns"/>

      </fileset>

    </copy>

    <copy todir="${uiproject.output.dir}">

      <fileset dir="${uiproject.src.dir}">

        <patternset refid="copy.patterns"/>

      </fileset>

    </copy>

  </target>

  <target name="allTests" description="runs Selenium tests"

          depends="init,clean,compile">

    <echo message="enter junit"></echo>

    <echo message="${uitest.name}"></echo>

    <junit printsummary="on" fork="true" haltonfailure="no">

      <classpath>

        <path refid="classpath"/>

        <pathelement location="${uitest.name}"/>

      </classpath>

      <formatter type="xml"/>

      <formatter type="plain"/>

      <test name="search"  failureproperty="selenium.tests.failed"/>

    </junit>

    <junitreport todir="${output.dir}">

      <fileset dir="${output.dir}"/>

      <report format="frames" todir="${output.dir}"/>

    </junitreport>

    <fail if="tests.failed"

          message="JSUnit tests failed, see output for details: ${output.dir}"/>

  </target>

</project>

<!-- Create the build directory structure used by compile -->

Thanks in advance.

-Varun

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2016
Added on Jan 25 2016
3 comments
613 views