Consider a user Account that contains the following members:

  • Username
  • Password
  • Account Type (User/Admin)
  • Security Question (Option of 5 choices)
  • Security Answer
  • A handful of booleans for various account specific settings.

How, can I design properly in order to build Objects of either Type User or Type Admin in a robust way where I can sometimes specify various data and other times, leave it empty / blank?

I want to create new Users and Admins, however their data (or the need to use such data) would vary massively. Maybe I want a user and I only want to specify its username + password, other times I want a User or Admin and specify ALL the members information.

What approach is best here?

  • What's your tech stack in automation? Commented Jan 23, 2018 at 12:23
  • Java for end2end stuff with selenium. its not so much the data-driven approach, im more concerned with the implementation so we can take data out of the question. Is Builder pattern with setter methods a viable option?
    – symon
    Commented Jan 23, 2018 at 17:17

2 Answers 2


Can you please try data-driven approach?

  • Separate your Users / Admins model away from actual data. Save your profile data in an external Excel sheet. This way, when you need to modify your profile data, there is no need to touch your code, thus maintenance is easier.

If you are just filling test data in UI, then go for a simpler solution like excel (as Yu Zhang suggested)or maybe json or xml based objects.

Always go for a simplest possible solution that will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.