Kenzo
17 years agoOccasional Contributor
write junit test in groovy script...
Hi there,
I have the following piece of code which is a junit test class to test a web page:
import junit.framework.*;
import com.thoughtworks.selenium.*;
import junit.textui.TestRunner;
public class Temp extends TestCase {
private Selenium browser;
public Temp(String name) {
super(name);
}
public void setUp() {
//some code
}
public static TestSuite suite() {
return new TestSuite(Temp.class);
}
public void test1(){
// some code
}
public void tearDown() {
// some code
}
public static void main(String[] args){
Temp test = new Temp("test");
TestRunner a = new TestRunner();
TestResult result = a.run(test.suite());
}
}
This works fine in eclipse but in groovy i get the error :
groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class Temp. Reason: java.lang.InstantiationException: Temp
why can't i instantiate the Temp class in groovy?
Any idea on how to work around this?
thanks,
I have the following piece of code which is a junit test class to test a web page:
import junit.framework.*;
import com.thoughtworks.selenium.*;
import junit.textui.TestRunner;
public class Temp extends TestCase {
private Selenium browser;
public Temp(String name) {
super(name);
}
public void setUp() {
//some code
}
public static TestSuite suite() {
return new TestSuite(Temp.class);
}
public void test1(){
// some code
}
public void tearDown() {
// some code
}
public static void main(String[] args){
Temp test = new Temp("test");
TestRunner a = new TestRunner();
TestResult result = a.run(test.suite());
}
}
This works fine in eclipse but in groovy i get the error :
groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class Temp. Reason: java.lang.InstantiationException: Temp
why can't i instantiate the Temp class in groovy?
Any idea on how to work around this?
thanks,