Junior — Middle
Have you created automated tests for your project?
sobes.tech AI
Answer from AI
Yes, automated tests are an important part of development, and I have created them for my Java projects.
I usually use JUnit for writing unit tests that check individual methods and classes. This helps quickly identify errors and maintain code quality.
Here's an example of a simple test with JUnit 5:
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class CalculatorTest {
@Test
void testAddition() {
Calculator calc = new Calculator();
int result = calc.add(2, 3);
assertEquals(5, result);
}
}
I can also write integration tests using Spring Boot Test or other frameworks to verify the interaction of application components.