facebook

junit tests give errors

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #254171 Reply

    cusdx
    Member

    Hi,

    I’m trying to run my junit tests in myEclipse. Is there a document somewhich explains how to do the set-up in myEclipse? (I originally developed them in Netbeans.) I have a class called AcceptanceTests.java which contains the main, so at its simplest I’m thinking I ought to be able to chose “Run As -> Java Application” from the context menu for that class, but that gives:

    java.lang.NoClassDefFoundError: uk/ac/warwick/omr/test/AcceptanceTests

    – my own class, which I’ve just right clicked on.

    Alternatively I’m trying what I think might be the way intended, which is to run my class OmrStudentTests.java, which extends TestCase, by picking “Run As -> JUnit Test” from the context menu – but that gives:

    Class not found uk.ac.warwick.omr.test.OmrStudentTests
    java.lang.ClassNotFoundException: uk.ac.warwick.omr.test.OmrStudentTests

    – again, my own class which I’ve just right clicked on.

    Guidance please!

    Zoe

    #254218 Reply

    Riyad Kalla
    Member

    Zoe,
    Each of the options you tried were fine. It sounds like you might actually have your build path setup incorrectly since you are getting such basic “class not found” exceptions.

    What does your project directory layout looking? Additionally, if you open your project properties and go to Java Build Path > Source, is the source directory and output directory setup appropriately?

    This is a web application I’m assuming?

    #254295 Reply

    cusdx
    Member

    Hi Riyad,

    You’re right that there is something awry with my project set-up – for instance I can’t build using Eclipse and just use ant to build my targets and deploy them on a different server. It was a project that someone else built in Netbeans and which I got going in myEclipse as best I could.

    Java Build Path Source shows ‘omr/WEB-INF/classes -> Included (All)’

    and the test class I am trying to run is under that directory, so that looks OK to me?

    My project directory looks like this:

    omr
    WEB-INF/classes (java classes are in here)
    <libraries>
    .myeclipse
    adHocJdoQueries (jsp’s under here)
    bin (mysterious directory created by Eclipse?)
    help (jsp’s under here)
    META-INF
    staff (jsp’s under here)
    student (jsp’s under here)
    upload (jsp’s under here)
    WEB-INF
    work
    <various dot files eg .cvsignore>
    <various jsp files>

    In addition there is a separate project which contains the build scripts and the etc directory called mleomr, from which I run the ant tasks.

    Does any of this help?

    #254296 Reply

    cusdx
    Member

    Sorry, the indents didn’t come out when I posted. “omr” is the name of the project and everything else is indented one level.

    #254299 Reply

    cusdx
    Member

    I checked “problems” and there were 4 errors referring to cyclical references in the build paths of projects OMR and MLEOMR. I discovered they each listed the other as a project on which they were dependent. Fixed that, and the rest cross disappeared and the tests are now running!

    Thanks for your help.

    #254310 Reply

    Riyad Kalla
    Member

    Nice job, glad it’s worknig now.

    For future reference you can maintain indents by using periods or you can just wrap things that need to stay formatted in code blocks (use the button below). Every forum has it’s own wonky-style-rules 😉

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: junit tests give errors

You must be logged in to post in the forum log in