-
Notifications
You must be signed in to change notification settings - Fork 8
/
RobolectricCoffeeMakerTest.java
45 lines (37 loc) · 1.15 KB
/
RobolectricCoffeeMakerTest.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
/*
* Copyright (c) 2018 Test Smells Project. All rights reserved.
* Author: Kosta Zaikin <[email protected]>
*/
package speed.unnecessary_robolectric;
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.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import sample.Bad;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.Assert.assertThat;
import static utils.SystemOutMatcher.has;
@Bad("Using RobolectricTestRunner when no android")
@RunWith(RobolectricTestRunner.class)
public class RobolectricCoffeeMakerTest {
@Mock Heater heater;
@Mock Pump pump;
ByteArrayOutputStream output = new ByteArrayOutputStream();
CoffeeMaker coffeeMaker;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
System.setOut(new PrintStream(output));
coffeeMaker = new CoffeeMaker(heater, pump);
}
@Test public void brew_makesCoffee() {
coffeeMaker.brew();
assertThat(output, has(CoffeeMaker.COFFEE));
}
}