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

Self Advertisement
—–Start of Advertisement——-
BUILD CAR POOL SOLUTIONS ON ANY DEVICE TO RUN ANYWHERE ( Introducing mCruiseOn, the java library /json api’s that you can use to build a car pool solution. Be the next,, 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.( 	at org.junit.internal.runners.JUnit38ClassRunner.( 	at 	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass( 	at 	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass( 	at org.junit.internal.requests.ClassRequest.getRunner( 	at org.junit.internal.requests.FilterRequest.getRunner( 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.( 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.( 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest( 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests( 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( 	at 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

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

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

  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.

      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: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s