0
0
Selenium Javatesting~5 mins

Base test class pattern in Selenium Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of a base test class in Selenium Java?
A base test class provides common setup and teardown methods for all test classes, reducing code duplication and improving maintainability.
Click to reveal answer
beginner
Which method is commonly used in a base test class to initialize the WebDriver before tests run?
A method annotated with @BeforeEach or @BeforeAll (JUnit) or @BeforeMethod (TestNG) is used to initialize the WebDriver before tests.
Click to reveal answer
intermediate
Why should locators and driver initialization be placed in the base test class?
Placing locators and driver initialization in the base class ensures all tests use the same setup, making tests consistent and easier to update.
Click to reveal answer
beginner
How does the base test class pattern help when adding new test cases?
New test classes can inherit from the base class and automatically get the setup and teardown, so testers only write test logic without repeating setup code.
Click to reveal answer
beginner
What is a common teardown method in the base test class and what does it do?
A method annotated with @AfterEach or @AfterAll (JUnit) or @AfterMethod (TestNG) closes the WebDriver to clean up resources after tests run.
Click to reveal answer
What is the main benefit of using a base test class in Selenium Java?
ATo share common setup and teardown code across tests
BTo write all tests in one big class
CTo avoid using WebDriver
DTo run tests without assertions
Which annotation is typically used to run setup code before each test in JUnit?
A@BeforeEach
B@BeforeAll
C@Test
D@AfterEach
Where should WebDriver initialization be placed when using the base test class pattern?
AInside each test method
BIn a separate utility class only
CIn the base test class setup method
DNot needed at all
What does the teardown method in the base test class usually do?
AStarts the browser
BCloses the browser and cleans up resources
CRuns assertions
DLogs test results
If you add a new test class, how does the base test class pattern help?
AYou need to create a new WebDriver instance manually
BYou must rewrite setup code
CYou cannot add new test classes
DYou inherit setup and teardown automatically
Explain the role of a base test class in Selenium Java testing and how it improves test code.
Think about what all tests need before and after running.
You got /5 concepts.
    Describe how you would organize WebDriver setup and cleanup using the base test class pattern.
    Consider test lifecycle annotations and resource management.
    You got /4 concepts.