LoganBlackisle

JUnit

Jun 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package prep_24_junit;
  2.  
  3. import static org.junit.jupiter.api.Assertions.*;
  4. import org.junit.jupiter.api.BeforeEach;
  5. import org.junit.jupiter.api.Test;
  6.  
  7. class JUnitTest {
  8.  
  9. @BeforeEach
  10. void setUp() throws Exception {
  11. }
  12.  
  13. @Test
  14. public void testAdd() {
  15. ClassToTest ctt = new ClassToTest(7, 42);
  16. assertEquals(49, ctt.add()); // 7+42 = 49 -> assert(expected, method to test)
  17. }
  18.  
  19. @Test
  20. void testSubtract() {
  21. ClassToTest ctt = new ClassToTest(53, 19);
  22. assertEquals(34, ctt.subtract()); // 53-19=34 -> assert(expected, method to test)
  23. }
  24.  
  25. @Test
  26. void testMultiply() {
  27. ClassToTest ctt = new ClassToTest(7, 6);
  28. assertEquals(42, ctt.multiply()); // 7*6=42 -> assert(expected, method to test)
  29. }
  30.  
  31. @Test
  32. void testDivide() {
  33. ClassToTest ctt = new ClassToTest(14, 7);
  34. assertEquals(2, ctt.divide()); // 14/7=2 -> assert(expected, method to test)
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment