This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Testing and the fly likes problem in running JUnit Test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "problem in running JUnit Test" Watch "problem in running JUnit Test" New topic
Author

problem in running JUnit Test

Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
Hello,
When I am doing my unit testing it is giving me class not found exception.
I have checked for all classpaths but mystery remains same.
can anybody tell me this?
here is my program--
package com.comput.Das;
import junit.framework.*;
import junit.extensions.*;
import com.ZTC_Das;
public class UnitJ extends TestCase{
public UnitJ(String arg1){
super(arg1);
}
public static void main(String ar[]){
junit.textui.TestRunner.run(suite());
}
public static UnitJ suite(){
return new UnitJ("com.ZTC_Das.class");
}
public void testString() {
try {
ZTC_Das objDML = new ZTC_Das();
String in="Hello World";
assertEquals("Hello World ",objDML.elxModifyString(in));
} catch(Exception ex){
System.out.println("Error Message="+ex);
}
}
}
Thanx in advance


Jack Nicholson
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Like, what class not found?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
parag Chatterjee
Greenhorn

Joined: Aug 02, 2002
Posts: 28
Hi,
I feel that you are writing the suite() method wrongly.
regds,
Parag
Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
I am getting error as ZTC_Das.class not found.
& I have tried suite() method in both ways like
public static UnitJ suite(){
return new UnitJ("ZTC_Das.class");
}
& also
public static UnitJ suite(){
return new UnitJ("com.ZTC_Das.class");
}
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
This works:

Maybe you can replace my class AAA with your whatsit.
Best way to learn about something is to fumble with someoneelse's problematic code...
Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
thanx Barry
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in running JUnit Test