File tree Expand file tree Collapse file tree 3 files changed +42
-7
lines changed 
src/test/java/me/kimihiqq Expand file tree Collapse file tree 3 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ dependencies {
1515
1616    testImplementation ' org.junit.jupiter:junit-jupiter-api:5.8.1' 
1717    testRuntimeOnly ' org.junit.jupiter:junit-jupiter-engine:5.8.1' 
18+     testImplementation ' org.mockito:mockito-core:3.12.4' 
19+ 
1820}
1921
2022
  Load Diff This file was deleted. 
Original file line number Diff line number Diff line change 1+ package  me .kimihiqq ;
2+ 
3+ import  me .kimihiqq .io .Input ;
4+ import  me .kimihiqq .io .Output ;
5+ import  org .junit .jupiter .api .Test ;
6+ import  org .mockito .Mockito ;
7+ import  static  org .mockito .Mockito .*;
8+ 
9+ public  class  CalculatorTest  {
10+ 
11+     @ Test 
12+     public  void  testCalculate () {
13+         Input  mockInput  = Mockito .mock (Input .class );
14+         Output  mockOutput  = Mockito .mock (Output .class );
15+ 
16+         when (mockInput .nextLine ()).thenReturn ("1 + 2 * 3" );
17+ 
18+         Calculator  calculator  = new  Calculator (mockInput , mockOutput );
19+         calculator .calculate ();
20+ 
21+         verify (mockOutput ).println ("7" );
22+     }
23+ 
24+     @ Test 
25+     public  void  testList () {
26+         Input  mockInput  = Mockito .mock (Input .class );
27+         Output  mockOutput  = Mockito .mock (Output .class );
28+ 
29+         when (mockInput .nextLine ()).thenReturn ("5 + 6" , "4 * 2" );
30+ 
31+         Calculator  calculator  = new  Calculator (mockInput , mockOutput );
32+         calculator .calculate ();
33+         calculator .calculate ();
34+ 
35+         calculator .list ();
36+ 
37+         verify (mockOutput ).println ("5 + 6 = 11" );
38+         verify (mockOutput ).println ("4 * 2 = 8" );
39+     }
40+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments