Why is it important to follow naming conventions for test classes in JUnit?
Think about how naming helps humans and tools recognize test code.
Proper naming helps developers and tools quickly find and organize tests, improving maintainability and clarity.
Given the following JUnit test classes, which one will be automatically detected and run by default JUnit 5 test runners?
public class CalculatorTest { @org.junit.jupiter.api.Test void testAdd() {} } public class CalculatorTests { @org.junit.jupiter.api.Test void testSubtract() {} } public class TestCalculator { @org.junit.jupiter.api.Test void testMultiply() {} } public class CalcTest { @org.junit.jupiter.api.Test void testDivide() {} }
JUnit 5 detects any class with @Test annotations regardless of name by default.
JUnit 5 does not require specific naming conventions to detect tests; it runs any class with @Test methods.
Which assertion correctly verifies that a test class name ends with 'Test' in a JUnit test?
String className = "CalculatorTest";Check the method that tests if a string ends with a specific suffix.
assertTrue with endsWith("Test") correctly checks the class name suffix.
Consider this JUnit 5 test class:
public class calculatorTest {
@org.junit.jupiter.api.Test
void testAdd() {}
}Why might this class cause confusion or issues in a team project?
Java class names should follow standard capitalization rules.
Class names should start with uppercase letters to follow Java conventions and avoid confusion.
Which statement correctly describes how JUnit 5 discovers test classes by default?
Think about how JUnit 5 improved test discovery compared to older versions.
JUnit 5 uses annotations to find tests, not naming or inheritance conventions.