Sobes.tech
Junior — Middle

Have you worked with test automation tools and code verification libraries?

sobes.tech AI

Answer from AI

Yes, I have worked with test automation tools in Java, such as JUnit and TestNG for writing unit tests. For code verification, I used libraries like Mockito for creating mock objects and verifying interactions, as well as Hamcrest for writing assertions conveniently.

Example of a simple test with JUnit 5:

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

class CalculatorTest {
    @Test
    void additionTest() {
        Calculator calc = new Calculator();
        assertEquals(5, calc.add(2, 3));
    }
}

Using Mockito for mocking:

import static org.mockito.Mockito.*;

List<String> mockedList = mock(List.class);
when(mockedList.get(0)).thenReturn("first");
assertEquals("first", mockedList.get(0));