Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6772011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:29:58+00:00 2026-05-26T15:29:58+00:00

Another classic ant junit problem. Like the other questions I found on the topic,

  • 0

Another classic ant junit problem. Like the other questions I found on the topic, it is probably some subtle classpath error but none of the suggested solutions have worked for me. Here is my test code, which runs just fine in Eclipse —

package trial;

import java.net.MalformedURLException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import trial.CommonCode;  //this is a library of methods, since the test runs I'm not including it here

public class BaseTests {
    WebDriver driver;
    CommonCode myCommon;

    @Before 
    public void startup() throws MalformedURLException, InterruptedException{
        myCommon=new CommonCode();
        driver=myCommon.driver;
    }

    @After
    public void cleanup(){
        driver.quit();
    }   

    @Test
    public void deleteLists(){
        System.out.println("Hi Mom!");
        myCommon.loginLibrary("GAL");

    }
}

And here’s my build.xml (class files are in ${workdir}\bin\trial and source files are in ${workdir}\src\trial)–

<project default="main" basedir=".">

    <property name="testbin" value="bin\trial"/>
    <property name="src.dir" value="src\trial"/>

    <path id="path.class">
      <pathelement location="c:\Java\selenium-2.8.0" /> 
      <pathelement location="C:\eclipse\plugins\org.junit_4.8.2.v4_8_2_v20110321-1705"/>
        <pathelement location="C:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300"/>
      <fileset dir="c:\Java\selenium-2.8.0" includes="*.jar" /> 
      <fileset dir="C:\eclipse\plugins\org.junit_4.8.2.v4_8_2_v20110321-1705" includes="*.jar"/>
        <fileset dir="C:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib" includes="*.jar"/>
      <path refid="src.dir" /> 
      </path>

    <path id="src.dir">
      <pathelement location="${src.dir}" /> 
      </path>

    <path id="test.dir">
        <pathelement location="${testbin}"/>
    </path>    

    <target name="main" depends="compile" description="main target">
        <echo> Building now </echo>
    </target>

    <target name="compile" description="compilation target" >
        <javac srcdir="${src.dir}" destdir="${testbin}" classpathref="path.class" debug="on" verbose="true"/>
    </target>

    <target name="runtest" >
            <junit fork="no" printsummary="true" showoutput="true">
                <classpath>
                    <path refid="path.class"/>
                    <path refid="test.dir"/>
                    <path refid="src.dir"/>
                </classpath>
                <formatter type="brief" usefile="false" />
                <batchtest fork="yes">
                    <fileset dir="${testbin}">                  
                        <include name="*Tests.class"/>
                    </fileset>
                </batchtest>

            </junit>

        </target>

</project>

I get the same error whether I run the ant task runtest from the command line or from eclipse ant pane:

runtest:
    [junit] Running BaseTests
    [junit] Testsuite: BaseTests
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    [junit] Null Test:  Caused an ERROR
    [junit] BaseTests (wrong name: trial/BaseTests)
    [junit] java.lang.NoClassDefFoundError: BaseTests (wrong name: trial/BaseTests)
    [junit]     at java.lang.ClassLoader.defineClass1(Native Method)
    [junit]     at java.lang.ClassLoader.defineClassCond(Unknown Source)
    [junit]     at java.lang.ClassLoader.defineClass(Unknown Source)
    [junit]     at java.security.SecureClassLoader.defineClass(Unknown Source)
    [junit]     at java.net.URLClassLoader.defineClass(Unknown Source)
    [junit]     at java.net.URLClassLoader.access$000(Unknown Source)
    [junit]     at java.net.URLClassLoader$1.run(Unknown Source)
    [junit]     at java.security.AccessController.doPrivileged(Native Method)
    [junit]     at java.net.URLClassLoader.findClass(Unknown Source)
    [junit]     at java.lang.ClassLoader.loadClass(Unknown Source)
    [junit]     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    [junit]     at java.lang.ClassLoader.loadClass(Unknown Source)
    [junit]     at java.lang.Class.forName0(Native Method)
    [junit]     at java.lang.Class.forName(Unknown Source)
    [junit] Test BaseTests FAILED

So it is finding the correct junit test (trial.BaseTests) but then claiming it has the wrong name. Any suggestions gratefully received, especially debugging hints so I can avoid this problem in the future.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:29:58+00:00Added an answer on May 26, 2026 at 3:29 pm

    It looks like your file paths are incorrect. They should match the package names.

    Your test class is trial.BaseTests. You are telling JUnit to execute all tests under bin/trial. So, it searchs for all files under bin/trial, and it finds BaseTests.class, which should be under trial/BaseTests.class.

    Change your testbin from ‘bin/trial’ to ‘bin’:

    <property name="testbin" value="bin"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Functional programming .. is like classic ( Mark Twain's type ). While reading another
Actually this is a classic problem as SO user Victor put it (in another
I am having some trouble with the classic javascript local variable scope topic, but
I have a classic ASP application I would like to add some AJAX-style partial
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
Another chapter from the arguments between myself and the other senior developer series :P
another sql problem of mine .. this time the reader doesn't work properly (
So Windows Embedded Compact 7 (another classic from the naming department) supports Silverlight for
I just changed a classic asp page to load a div with some data
This is a classic CS problem I encountered in my work: I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.