Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package prep_24_junit;
- import static org.junit.jupiter.api.Assertions.*;
- import org.junit.jupiter.api.BeforeEach;
- import org.junit.jupiter.api.Test;
- class JUnitTest {
- @BeforeEach
- void setUp() throws Exception {
- }
- @Test
- public void testAdd() {
- ClassToTest ctt = new ClassToTest(7, 42);
- assertEquals(49, ctt.add()); // 7+42 = 49 -> assert(expected, method to test)
- }
- @Test
- void testSubtract() {
- ClassToTest ctt = new ClassToTest(53, 19);
- assertEquals(34, ctt.subtract()); // 53-19=34 -> assert(expected, method to test)
- }
- @Test
- void testMultiply() {
- ClassToTest ctt = new ClassToTest(7, 6);
- assertEquals(42, ctt.multiply()); // 7*6=42 -> assert(expected, method to test)
- }
- @Test
- void testDivide() {
- ClassToTest ctt = new ClassToTest(14, 7);
- assertEquals(2, ctt.divide()); // 14/7=2 -> assert(expected, method to test)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment