M BUZZ CRAZE NEWS
// general

Junit4 giving "no tests found" when running junit on simple test cases

By Gabriel Cooper

I need some help getting junit4 working on ubuntu 14.04. I have installed junit correctly (I hope!), when I use junit -v in the terminal it returns junit 4.11. However when I compile with javac: javac TestCase.java and the run junit TestCase it returns no tests found.

My simple test code is:

 import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class ClubMemberTest{ @Test public void test1(){ assertTrue(1-1==0); } }

I have put junit4.jar and junit4-4.11.jar in my CLASSPATH variable using the .bashrc file.

I'm still pretty new to linux & ubuntu so any and all help would be greatly appreciated!

0

1 Answer

Of course not. Your class ClubMemberTest have to extend junit.framework.TestCase

import org.junit.Test;
import junit.framework.TestCase;
public class ClubMemberTest extends TestCase { @Test public static void test1() { assertTrue(1 - 1 == 0); }
}
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy