vendredi 24 janvier 2020

What kind of test shall I use in my spring project(and am I doing it right)?

My project is a simple management system for shop which is connected to MySQL database.

I only have JUnit test like this one(is this test written correctly?):

@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public class EmployeeRepositoryIntegrationTest
{
    @Autowired
    private TestEntityManager entityManager;

    @Autowired
    private EmployeeRepository employeeRepository;

    @Test
    public void whenFindByLastName_thenReturnEmployee()
    {
        User employee = new User("UserName","password","John",
                        "Smith","Adress Test","123123123","CityTest");

        entityManager.persist(employee);
        entityManager.flush();

        User result = userRepository.findUserByLastName(employee.getLastName()).get(0);
        assertThat(result.getLastName()).isEqualTo(employee.getLastName());
    }
}

Should I add Mockito Tests, and what kind of test should I add in future?

Aucun commentaire:

Enregistrer un commentaire