Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package bg.sofia.uni.fmi.mjt.chat;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.powermock.api.mockito.PowerMockito.mock;
  4. import static org.powermock.api.mockito.PowerMockito.whenNew;
  5.  
  6. import java.io.FileInputStream;
  7.  
  8. import org.junit.Test;
  9. import org.junit.runner.RunWith;
  10. import org.powermock.core.classloader.annotations.PrepareForTest;
  11. import org.powermock.modules.junit4.PowerMockRunner;
  12.  
  13. @RunWith(PowerMockRunner.class)
  14. @PrepareForTest(FileInputStream.class)
  15. public class Class1Test {
  16.  
  17.     @Test
  18.     public void method1Test() throws Exception {
  19.  
  20.         Class1 class1 = new Class1();
  21.  
  22.         FileInputStream fileInputStreamMock = mock(FileInputStream.class);
  23.  
  24.         whenNew(FileInputStream.class).withAnyArguments()
  25.                 .thenReturn(fileInputStreamMock);
  26.  
  27.         boolean expected = true;
  28.         boolean actual = class1.method1();
  29.  
  30.         assertEquals(expected, actual);
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement