-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathHelloWorldTest.java
More file actions
35 lines (27 loc) · 894 Bytes
/
HelloWorldTest.java
File metadata and controls
35 lines (27 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import org.junit.Test;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class HelloWorldTest {
@Test
public void hello_world_test() {
//given
Dependency dependency = new Dependency();
HelloWorld helloWorld = new HelloWorld(dependency);
//when
String actual = helloWorld.beenCalled();
//then
assertThat(actual).isEqualTo("Leave me alone.");
}
@Test
public void should_be_mocked() {
//given
Dependency dependency = mock(Dependency.class);
when(dependency.say()).thenReturn("Hello World");
HelloWorld helloWorld = new HelloWorld(dependency);
//when
String actual = helloWorld.beenCalled();
//then
assertThat(actual).isEqualTo("Hello World");
}
}