So I am learning Spring Boot and reached testing, while learning testing specifically Unit Testing with JUnit and Mockito, I realized that I would need to create a unit test or function for every method and create reach Happy Path (Everything goes right) and Negative Path (Something went wrong). While trying to create my own testing I realized that it would take up too much of my time to create unit tests for all my methods from my project.
My question is does companies that uses Spring Boot requires creating Unit Testing for the entire project?. What if the project is too big wouldn't it take up so much time and might delay shipping of features?.
I also want to ask if its okay if we ask AI to those unit testing instead. Since AI is much faster than writing the code for testing manually.
//DISABLE ACCOUNT (ACCOUNT ALREADY DISABLED)
u/Test
void shouldThrowExceptionWhenUserIsAlreadyDisabled(){
//ARRANGE
Roles fakeRole = new Roles();
fakeRole.setRoleName("Frontdesk");
Users fakeUser = new Users();
fakeUser.setFirstName("John");
fakeUser.setLastName("Doe");
fakeUser.setRole(fakeRole);
fakeUser.setAccountStatus(AccountStatus.
Disabled
);
when
(usersRepository.findById(1)).thenReturn(Optional.
of
(fakeUser));
//ACT + ASSERT
assertThrows
(NoChangesDetected.class, () -> {
usersService.disableAccount(1);
});
}