How to run JUnit tests on Cloud9?

java

#1

Hello everyone! I have set up Cloud9 with java. I am able to compile my regular java classes, however, when I try to compile and run the test class, it doesn’t recognize JUnit.
Here’s the error I get:

Problem1Test.java:1: error: package org.junit does not exist
import static org.junit.Assert.*;
                       ^
Problem1Test.java:2: error: package org.junit does not exist
import org.junit.Test;
                ^
Problem1Test.java:6: error: cannot find symbol
        @Test
         ^
  symbol:   class Test
  location: class Problem1Test
Problem1Test.java:14: error: cannot find symbol
        @Test
         ^
  symbol:   class Test
  location: class Problem1Test
Problem1Test.java:11: error: cannot find symbol
                assertEquals(23, p1.multiples(n));
                ^
  symbol:   method assertEquals(int,int)
  location: class Problem1Test
Problem1Test.java:19: error: cannot find symbol
                assertEquals(-1, p1.multiples(n));
                ^
  symbol:   method assertEquals(int,int)
  location: class Problem1Test
6 errors

Is there a way to run JUnit tests? Or is there a tutorial I could use to do this?
Thank you!


#2

Though I can’t offer much in the world of Java or JUnit, I can say that this should work just how it would on a local Linux machine (unless JUnit requires a GUI). As long as you’ve installed all necessary JUnit packages properly it should run from the command line but I’m not speaking from experience :blush:


#3

Can you give an example of your test source code?


#4

I think what we need, (I’m having the exact same issue) is how to install the additional libraries in cloud 9. The error says:

error: package org.junit does not exist
import static org.junit.Assert.*;

I think there must be content missing from the open JDK that’s installed with:
sudo apt-get install default-jdk
JUNIT framework must not be included? thoughts? (Oh the same applies to JAVAX messaging too.)