public class Greeter {
Note: if you are creating a test file for a class that does not
have a class source code file in the module (for example the String
or Calendar class in the Java Class Library), first create a dummy class,
for example with name FakeClass in the source code file
FakeClass.java.
import static org.junit.jupiter.api.Assertions.*; class GreeterTest { @org.junit.jupiter.api.BeforeEach void setUp() { } @org.junit.jupiter.api.Test void makeGreeting() { } }
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class GreeterTest {
@BeforeEach
void setUp() {
}
@Test
void makeGreeting() {
}
}
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class GreeterTest {
@BeforeEach
void setUp() {
// This method initializes objects that
// are used in each test method.
// This method is not needed for the
// GreeterTest class.
}
@Test
void test1( ) {
assertEquals("Hello, Alice, how are you?",
Greeter.makeGreeting("Alice");
}
}