nu l testing does not sc le • Regression issues ppe r frequently • Tests provide con idence during ref ctoring a a a a a a f a a a a a • Softw re engineering relies on utom tion
src/test/j v → Test code • pom.xml → Dependencies nd build con igur tion • mvn test → Execute utom ted tests • Maven automatically discovers test classes • JUnit tests execute during the build process a f a a a a a a a a a • Builds fail if tests fail
v testing fr mework • Tests re written s J v methods @Test • Assertions verify expected beh vior • Set up your objects • Tests should be isol ted nd repe t ble • Execute behavior • Assert a a a a a a a a a a a a a a // assertEquals(expected, // actual) // assertTrue(condition) // assertThrows(exception, code)
outline, not complete setup code. @Test void publisherReachesSubscriber() throws Exception { // Connect two clients with unique IDs. // Subscriber subscribes to a unique test topic. // Callback checks payload and calls received.countDown(). // Publisher sends the expected payload. assertTrue(received.await(5, TimeUnit.SECONDS)); // Disconnect and close both clients in finally/tearDown. } 14
Fall 2026 Copyright Notice. These slides are provided exclusively for educational use in CSC 3100 within the California State University system. Redistribution or use for any other purpose is prohibited without prior written permission.