Sobes.tech
Junior — Middle

Do you use abstract classes in your practice for architectural solutions?

sobes.tech AI

Answer from AI

Yes, abstract classes are often used in architectural solutions, especially in test automation and QA, to create basic templates and contracts that must be implemented by concrete classes.

An abstract class allows defining common methods and properties, as well as declaring abstract methods that must be implemented in subclasses. This helps standardize the structure of tests, components, or utilities.

For example, in test automation, you can create an abstract class for a base test with setup and teardown methods, and specific tests will inherit this class and implement specific checks:

public abstract class BaseTest {
    @Before
    public void setup() {
        // Common test environment setup
    }

    @After
    public void teardown() {
        // Common actions after test
    }

    public abstract void runTest();
}

public class LoginTest extends BaseTest {
    @Override
    public void runTest() {
        // Implementation of specific test
    }
}

Thus, abstract classes help maintain a clean architecture and reusability of code.

Do you use abstract classes in your practice for… - sobes.tech