java.lang.RuntimeException: Stub! at junit.framework.TestSuite.(TestSuite.java:7)


Self Advertisement
—–Start of Advertisement——-
BUILD CAR POOL SOLUTIONS ON ANY DEVICE TO RUN ANYWHERE (www.mcruiseon.com). Introducing mCruiseOn, the java library /json api’s that you can use to build a car pool solution. Be the next avego.com, carpooling.com, zimride.com. mCruiseOn is your one stop API on EC2.
——End of Advertisement——-

This has been driving me crazy for the last few days. Late nights and my sleep. All I wanted to do was integrate junit early on the project so that I can start unit testing. So my setup is simple, eclipse, java project (writing my server piece), hibernate and junit. Every time I write just a simple

package com.mcruiseon.server.testcase;
import java.util.ArrayList;
import org.hibernate.SessionFactory;
import junit.framework.TestCase;
import org.junit.Test;

public class HibernateConnectionTest extends TestCase {	
	@Test public void testInsertRow() {
		assertEquals(0,0) ;
	}
}

This above code would throw nasty exception

java.lang.RuntimeException: Stub! 	at junit.framework.TestSuite.(TestSuite.java:7) 	at org.junit.internal.runners.JUnit38ClassRunner.(JUnit38ClassRunner.java:67) 	at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:14) 	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) 	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24) 	at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:34) 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:29) 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.(JUnit4TestMethodReference.java:25) 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41) 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30) 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I googled like crazy, logged bugs with junit, all I could find is issues reported with maven. Finally I hit a bug on junit, and identified the root cause.

Dont smile!!!

Move the junit dependency up the chain on your referenced libraries and it worked :).

Have fun

Advertisements

10 thoughts on “java.lang.RuntimeException: Stub! at junit.framework.TestSuite.(TestSuite.java:7)

  1. I had andriod jar on top of the ref. libs and got the same exception. Moved junit to top, it worked perfectly…

  2. Pingback: java.lang.RuntimeException: Stub!

    • I did this in IntelliJ IDEA version 14, maybe someone else can comment for Eclipse.

      Steps:
      1) File -> Project Structure
      2) On the left, select Modules
      3) In the middle, select the topmost package
      4) On the right, select ‘Dependencies’
      5) Here you can move your dependencies up and down with the arrows.

  3. Pingback: java.lang.RuntimeException: Stub!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s