Context I've just started working with Java (Ruby background), and need to test-drive a Hello World CLA. I'm using JUnit (no managers like Gradle/Maven), but cannot compile my test to run it.
Structure
HelloWorldJava/src
- main/java/HelloWorld.java
- test/java/HelloWorldTest.java
Program
public class HelloWorld{
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Test
import org.junit.*;
import static org.junit.jupiter.api.Assertions.*;
import example.util.Calculator;
import org.junit.jupiter.apiTest;
class HelloWorldTest {
@Test
public void testAddition() {
HelloWorld helloWorld = new HwlloWorld();
assertTrue(helloWorld.equals("Hello World!"));
}
}
Problem
From src: $ java -cp :'./test/java/*' HelloWorldTest.java
returns
Error: Could not find or load main class HelloWorldTest.java
My best guess is that it's something to do with the classpath, but the error isn't giving much.
What do I need to do to compile and run my tests? I have tried changing the test method to 'main', which doesn't change the error.
Edit: I have looked at similar questions and haven't succeeded in implementing a solution.