Developer 역할 Spring 골격 smoke #4
1 changed files with 55 additions and 0 deletions
55
src/test/java/com/example/demo/service/HelloServiceTest.java
Normal file
55
src/test/java/com/example/demo/service/HelloServiceTest.java
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.example.demo.service;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
@DisplayName("HelloService Unit Tests")
|
||||||
|
class HelloServiceTest {
|
||||||
|
|
||||||
|
private HelloService helloService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
helloService = new HelloService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("getGreeting returns default greeting")
|
||||||
|
void getGreeting_ReturnsDefaultGreeting() {
|
||||||
|
String result = helloService.getGreeting();
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("Hello, World!", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("getGreetingFor returns personalized greeting")
|
||||||
|
void getGreetingFor_ReturnsPersonalizedGreeting() {
|
||||||
|
String result = helloService.getGreetingFor("Developer");
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("Hello, Developer!", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("getGreetingFor with null returns default greeting")
|
||||||
|
void getGreetingFor_WithNull_ReturnsDefaultGreeting() {
|
||||||
|
String result = helloService.getGreetingFor(null);
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("Hello, World!", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("getGreetingFor with blank string returns default greeting")
|
||||||
|
void getGreetingFor_WithBlankString_ReturnsDefaultGreeting() {
|
||||||
|
String result = helloService.getGreetingFor(" ");
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("Hello, World!", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue