Sobes.tech
Junior — Middle

What tools and libraries for automated testing do you use in your practice?

sobes.tech AI

Answer from AI

In practice of automated testing in Java, I often use the following tools and libraries:

  • JUnit — the main framework for writing unit tests.
  • TestNG — an alternative to JUnit with extended capabilities, such as test parameterization.
  • Mockito — a library for creating mock objects and simulating dependency behavior.
  • Selenium WebDriver — for automating web interface testing.
  • AssertJ — for convenient and readable assertions in tests.
  • Allure — for generating reports based on test results.

Example of a simple test with JUnit and Mockito:

import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.*;

class UserServiceTest {
    @Test
    void testGetUserName() {
        UserRepository repo = mock(UserRepository.class);
        when(repo.findNameById(1)).thenReturn("Ivan");

        UserService service = new UserService(repo);
        String name = service.getUserName(1);

        assertEquals("Ivan", name);
    }
}
What tools and libraries for automated testing do you… - sobes.tech