Fwd: JUnit "Could not find class" = Newbie Help

"David Saff" <[email protected]> Mon, 18 Aug 2008 11:04:04 -0400
Newsgroups gmane.comp.java.junit.devel
Message-ID <[email protected]>
Forgot (again) to copy list


---------- Forwarded message ----------
From: Peter Laurens <[email protected]>
Date: Mon, Aug 18, 2008 at 11:03 AM
Subject: Re: [Junit-devel] JUnit "Could not find class" = Newbie Help
To: David Saff <[email protected]>


Hi David, thanks that's a great help, I'll bookmark that address.

I didn't actually get an answer, but I resorted to using Eclipse and
having it sort out path setup and compilation with JUnit for me rather
than do it by hand, and although that wasn't what I wanted to do
originally, it did work.

Thanks!

- Peter

On 18 Aug 2008, at 15:57, David Saff wrote:

> Peter,
>
> [email protected] is the user list for JUnit, and is more likely
> to get you quick responses to such questions.  Did you find an answer?
>
>  David
>
> On Thu, Feb 21, 2008 at 6:10 PM, Peter Laurens
> <[email protected]> wrote:
>>
>> Hi,
>>
>> I am seeking a little help getting up and running with JUnit -
>> hopefully this is the right list.
>>
>> I have installed the JUnit jar in my extensions folder, and it works
>> properly, however, when I run it I get the error:
>>
>> "Could not find class: org.xxx.powersim.ModelTest
>> Time: 0
>> OK (0 tests)
>> Java Result: 1"
>>
>>
>> ModelTest has been compiled properly, and looks like this:
>>
>> package org.xxx.powersim;
>>
>> import org.junit.*;
>> import static org.junit.Assert.*;
>> import java.util.*;
>>
>> public final class ModelTest {
>>
>>      public static void main(String args[]) {
>>            org.junit.runner.JUnitCore.main("org.xxx.powersim.ModelTest");
>>          }
>>
>>      @Test
>>      public void testJunit() {
>>              assertTrue(true);
>>      }
>> }
>>
>> Pretty simple stuff.
>>
>> As you can see I'm trying to use the 'main' method of the test to
>> execute the test itself... but I've tried running it via the runner
>> from the command line also: "java org.junit.runner.JUnitCore
>> org.xxx.powersim.ModelTest". I get the same result.
>>
>> It might be a package issue, so here's how I have things set up in the
>> file system:
>>
>> /PowerSim
>>      /build
>>              /org
>>                      /xxx
>>                              /powersim
>>                                      - ModelTest.class
>>      /src
>>              /org
>>                      /xxx
>>                              /powersim
>>                                      -ModelTest.java
>>
>>
>>
>> I've tried running it within Ant, by hand, from within TextMate's
>> built-in bundle - I get the same result. JUnit is installed and
>> running fine, but it can't seem to see the test class - the more I
>> think about it this is a package problem that I'm just not sure how to
>> fix. I've tried running it by hand in the root /PowerSim directory, in
>> the /build folder, and in the /powersim class where ModelTest is. I
>> still get the error that "Could not find class:
>> org.xxx.powersim.ModelTest". My files compile just fine with my simple
>> Ant script which is as follows:
>>
>>
>>
>> <?xml version="1.0"?>
>> <project name="PowerSim" default="run" basedir=".">
>>  <property name="src" value="./src"/>
>>  <property name="build" value="./build"/>
>>  <property name="compile.debug"       value="true"/>
>>
>>  <path id="compile.classpath">
>>   <pathelement location="${mysql.jdbc}"/>
>>   <pathelement location="${junit.jar}"/>
>>  </path>
>>
>>   <target name="build" depends="init">
>>       <javac srcdir="${src}"
>>              destdir="${build}"
>>              debug="${compile.debug}"
>>              source="1.5">
>>          <classpath refid="compile.classpath"/>
>>       </javac>
>>   </target>
>>
>>
>>  <target name="init">
>>   <mkdir dir="${build}"/>
>>  </target>
>>
>>
>>  <target name="run" depends="build">
>>   <java classname="org.xxx.powersim.Model"
>>       fork="true"
>>       dir="${build}"
>>       classpath="${build}"
>>       maxmemory="500m">
>>   </java>
>>   </target>
>>
>>      <target name="test" depends="build">
>>          <java classname="org.xxx.powersim.ModelTest"
>>              fork="yes"
>>              dir="${build}"
>>              classpath="${build}"
>>              maxmemory="500m">
>>          </java>
>>          </target>
>>
>>  <target name="clean" description="Removes previous build">
>>   <delete verbose="true">
>>     <fileset dir="${build}"/>
>>   </delete>
>>  </target>
>>
>> </project>
>>
>>
>> As you can see, I'm not sure what to try next - any help would be much
>> appreciated.
>>
>> Thanks again,
>>
>> - Peter
>>
>>
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Junit-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/junit-devel
>>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/