Add oving0
This commit is contained in:
35
src/test/java/oving0/EnvironmentTest.java
Normal file
35
src/test/java/oving0/EnvironmentTest.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package oving0;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test checks if you have the correct version of Java installed.
|
||||
*/
|
||||
public class EnvironmentTest {
|
||||
|
||||
private static final int RECOMMENDED_JAVA_VERSION = 25;
|
||||
|
||||
@Test
|
||||
public void testJavaVersion() {
|
||||
int javaVersionNumber = this.getVersion();
|
||||
assertEquals(RECOMMENDED_JAVA_VERSION, javaVersionNumber,
|
||||
"Wrong Java version! We recommend that you use " + RECOMMENDED_JAVA_VERSION);
|
||||
}
|
||||
|
||||
private int getVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
|
||||
if (version.startsWith("1.")) {
|
||||
version = version.substring(2, 3);
|
||||
} else {
|
||||
int dot = version.indexOf(".");
|
||||
|
||||
if (dot != -1) {
|
||||
version = version.substring(0, dot);
|
||||
}
|
||||
}
|
||||
|
||||
return Integer.parseInt(version);
|
||||
}
|
||||
}
|
||||
25
src/test/java/oving0/HelloWorldTest.java
Normal file
25
src/test/java/oving0/HelloWorldTest.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package oving0;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HelloWorldTest {
|
||||
|
||||
private HelloWorld helloWorld;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
helloWorld = new HelloWorld();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHelloWorld() {
|
||||
assertEquals("Hello World!", helloWorld.getHelloWorld());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHelloWorldLength() {
|
||||
assertEquals(12, helloWorld.getHelloWorldLength());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user