-
Notifications
You must be signed in to change notification settings - Fork 8
/
CoffeeMakerTest.java
57 lines (46 loc) · 1.56 KB
/
CoffeeMakerTest.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Copyright (c) 2018 Test Smells Project. All rights reserved.
* Author: Kosta Zaikin <[email protected]>
*/
package naming.no_action_or_assertion;
import coffee.CoffeeMaker;
import coffee.Heater;
import coffee.Pump;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import sample.Bad;
import sample.Good;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.Assert.assertThat;
import static utils.SystemOutMatcher.has;
@RunWith(MockitoJUnitRunner.class)
public class CoffeeMakerTest {
@Mock private Heater heater;
@Mock private Pump pump;
private ByteArrayOutputStream output = new ByteArrayOutputStream();
private CoffeeMaker coffeeMaker;
@Before
public void setUp() {
System.setOut(new PrintStream(output));
coffeeMaker = new CoffeeMaker(heater, pump);
}
@Bad("It is not clear what action is performed and what is being checked")
@Test public void testCoffeeMaker() {
coffeeMaker.brew();
assertThat(output, has(CoffeeMaker.COFFEE));
}
@Good("It is clear a coffee should be made, but it is not clear what action is performed")
@Test public void shouldMakeCoffee() {
coffeeMaker.brew();
assertThat(output, has(CoffeeMaker.COFFEE));
}
@Good("From the name it is clear a coffee is checked after brew. Perfect.")
@Test public void brew_makesCoffee() {
coffeeMaker.brew();
assertThat(output, has(CoffeeMaker.COFFEE));
}
}