Skip to content

Instantly share code, notes, and snippets.

@hw0k
Created November 27, 2018 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hw0k/677750bf0253f772771532470d00f313 to your computer and use it in GitHub Desktop.
Save hw0k/677750bf0253f772771532470d00f313 to your computer and use it in GitHub Desktop.
Writing JUnit Test Case Practice
public class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPersonInfo() {
return this.name + "님은 " + this.age + "세 입니다.";
}
}
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class PersonTest {
private Person person;
@Before
public void init() {
person = new Person("hw0k", 18);
}
@Test
public void testGetPersonInfo() {
assertEquals(person.getPersonInfo(), "hw0k님은 18세 입니다.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment