How To Use JUnit Testing

By Nick Newcomer

About JUnit Testing

Junit Testing is a way that students can efficiently check implementations of their methods of code by using the Assertions package within the Jupiter library.

JUnit Jupiter Library



Requirements

Import Statements

                import static org.junit.api.Assertions.assertEquals;
                import static org.junit.api.Assertions.assertTrue;
                import static org.junit.api.Assertions.assertFalse;
                import static org.junit.api.Assertions.assertNull;
                import static org.junit.api.Assertions.fail;
            
                assertEquals(expected, actual);
                assertTrue(methodName, message if false);
                assertFalse(methodName, message if false);
                assertNull(data, message if not null);
                fail(message);
            

Class Declaration

                public class ClassNameTests {
                    @Test
                    public void test1() {
                        ...
                    }
                }