File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 "difficulty" : 1 ,
1111 "topics" : []
1212 },
13+ {
14+ "slug" : " two-fer" ,
15+ "difficulty" : 1 ,
16+ "topics" : []
17+ },
1318 {
1419 "slug" : " rna-transcription" ,
1520 "difficulty" : 2 ,
Original file line number Diff line number Diff line change @@ -67,5 +67,6 @@ include 'sum-of-multiples'
6767include ' triangle'
6868include ' trinary'
6969include ' twelve-days'
70+ include ' two-fer'
7071include ' word-count'
7172include ' wordy'
Original file line number Diff line number Diff line change 1+ apply plugin : " java"
2+ apply plugin : " eclipse"
3+ apply plugin : " idea"
4+
5+ repositories {
6+ mavenCentral()
7+ }
8+
9+ dependencies {
10+ testCompile " junit:junit:4.12"
11+ }
12+ test {
13+ testLogging {
14+ exceptionFormat = ' full'
15+ events = [" passed" , " failed" , " skipped" ]
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ public class Twofer {
2+ public String twofer (String name ) {
3+ return "One for " + (name != null ? name : "you" ) + ", one for me." ;
4+ }
5+ }
Original file line number Diff line number Diff line change 1+ public class Twofer {
2+ public String twofer (String name ) {
3+ throw new UnsupportedOperationException ("Delete this statement and write your own implementation." );
4+ }
5+ }
Original file line number Diff line number Diff line change 1+ import org .junit .Before ;
2+ import org .junit .Ignore ;
3+ import org .junit .Test ;
4+
5+ import static org .junit .Assert .assertEquals ;
6+
7+ public class TwoferTest {
8+
9+ private Twofer twofer ;
10+
11+ @ Before
12+ public void setup () {
13+ twofer = new Twofer ();
14+ }
15+
16+ @ Test
17+ public void noNameGiven () {
18+ String input = null ;
19+ String expected = "One for you, one for me." ;
20+
21+ assertEquals (expected , twofer .twofer (input ));
22+ }
23+
24+ @ Test
25+ @ Ignore ("Remove to run test" )
26+ public void aNameGiven () {
27+ String input = "Alice" ;
28+ String expected = "One for Alice, one for me." ;
29+
30+ assertEquals (expected , twofer .twofer (input ));
31+ }
32+
33+ @ Test
34+ @ Ignore ("Remove to run test" )
35+ public void anotherNameGiven () {
36+ String input = "Bob" ;
37+ String expected = "One for Bob, one for me." ;
38+
39+ assertEquals (expected , twofer .twofer (input ));
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments