Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in running JUnit Test

 
Jack Nicholson
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like, what class not found?
 
parag Chatterjee
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I feel that you are writing the suite() method wrongly.
regds,
Parag
 
Jack Nicholson
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx Barry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic