Revenue test (JUnit5) - Finovara
Hello! After the latest update to my project, I decided it was the perfect time to finally start writing tests for Finovara . So far, I've written tests for the main methods. On average, I run 2-3 tests per method, which seems like a good compromise. I cover both the happy path and a few edge cases and alternate flows—basically, I try to make sure everything works as expected , regardless of the situation. Overall, I'm aiming for 70-80% code coverage , though this may change as I add more tests and improve what I already have. Example of a simple test: @Test void shouldAddRevenueSuccessfully () { RevenueDTO dto = new RevenueDTO ( null , null , new BigDecimal ( "100" ), RevenueCategory . SALARY , null , "test income" ); String email = "test@test.com" ; User user = new User (); when ( timeConfig . clock ()). thenReturn ( Clock . systemDefaultZone ()); when ( userManagerService . getUserByEmailOrThrow ( email )). thenReturn ( user ); revenueService . addRevenue ( dto , email ); verify ( w
Continue reading on Dev.to Webdev
Opens in a new tab



