dcsimg
how to run single test in junit 4 from a main method
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   boy_j
Posted On:   Tuesday, February 1, 2011 03:26 AM

public class TESTCLASS { @Before public void setUp(){ //some setup } @Test public void testA() { //some test } @Test public void testB(){ //some test } @Test public void testB(){ //some test } } To run a single method testB in the above class I have code in a main() as below new TestRunner().start(new String[]{"-c","TESTCLASS","-m","TESTCLASS.testB"}); but this doesn't work and i get an error like this Exception in thread "main" java.lang.Exception: Could not    More>>
			
public class TESTCLASS {

@Before
public void setUp(){
//some setup
}

@Test
public void testA() {
//some test
}

@Test
public void testB(){
//some test
}

@Test
public void testB(){
//some test
}
}


To run a single method testB in the above class I have code in a main() as below



new TestRunner().start(new String[]{"-c","TESTCLASS","-m","TESTCLASS.testB"});




but this doesn't work and i get an error like this



Exception in thread "main" java.lang.Exception: Could not create and run test suite: java.lang.ClassCastException: class TESTCLASS at junit.textui.TestRunner.start(TestRunner.java:182)





I am trying to execute a method selected in a swing application. At the end i would want to get a list of selected methods in the swing gui to be executed. how do i do this ?

   <<Less
About | Sitemap | Contact