December 11, 2018

What software design principles do you use writing UI automation frameworks? Do you use SOLID?

When crafting automation frameworks, do you use SOLID software design principles in your work? If so, could you provide some examples?  

Ever since I've been tasked to create a Capybara + Ruby UI automation framework, I've been reading  books such as Robert "Uncle Bob" C. Martin's Clean Architecture: A Craftman's Guide to Software Structure and Design (2018) and his Agile Software Development, Principles, Patterns, and Practices (2002), trying to glean some insight on how to improve what I am doing.

The SOLID object oriented design principles, a mnemonic created by Michael Feathers based on principles Uncle Bob had collected are a bit beyond me at the moment. Attempting to study about the Single responsibility principle, Open/closed principle, Liskov substitution principle, Interface segregation principle and the Dependency inversion principle, trying to see how I can apply them is giving me a headache.

I fully recommend Angie Jones' webinar, Applying the Pillars of Object Oriented Frameworks to Test Automation for anyone who needs a refresher on Encapsulation, Inheritance, Polymorphic and Abstraction. I wish there was something like this for SOLID design principles!

Here are some of the principles I follow when writing automation frameworks:

DRY
  • Don't Repeat Yourself.  Instead of copying-and-pasting code, I factor out commonly used code snippets, placing the block of code into a library I can then reuse. 

YAGNI
  • You Ain't Going To Need It. Instead of plotting out every single selector on a page that locates a web element in a user-interface, I focus on just what I need for the current two week sprint. Every single time I try to plan ahead, priorities change, shift, reshape, and by the time I finally get back to the prepwork, everything has changed.

Abstraction
  • If there is a Login screen, I create a Login page object, which stores all the locators that interact with the web elements such as the username & password textbox, and the Login button. It also would have a LOGIN method where a test could pass in a username and password and be logged into the System Under Test.

Encapsulation
  • Within Page Objects, I declare public methods that then interact with the private variables storing the selectors for the web elements on the page. 

Inheritance
  • Are there commonly used elements on the page? I create a Base Page Object which contain commonly used methods that other pages can inherit.
These principles? I find them easy to understand and use. SOLID Principles? Not so much.

Any help that you could give would be much appreciated. I will craft a response blog post from the answers I receive. 

Oh, and don't get me started on how lost I am about the Gang of Four's Design Patterns: Elements of Reusable Object-Oriented Software (1994)!



Happy Testing?

-T.J. Maher
Sr. QA Engineer, Software Engineer in Test
Meetup Organizer, Ministry of Testing - Boston

Twitter | YouTubeLinkedIn | Articles

23 comments:

  1. Hey TJ,
    Thanks for that article and this is a great conversation that you've started.

    I still owe you an article on SRP, which I believe to be the easiest to use and one that has drastic impacts on test automation. OOP is also good to keep in mind as we design systems. I find it extremely useful when dealing with switch statements. Right away when I have switch statements I know that they are breaking OOP principle, so I replace them with factories.

    The other ones, I keep in mind but I rarely find use for them. DIP is extremely useful if you are trying to write a system that is unit testable. Sometimes I found myself needing to write unit tests for some of my methods that get more complex. In that case, DIP is useful because it allows me to inject mocks or stubs into my unit tests.

    ReplyDelete
  2. It is the intent to provide valuable information and best practices, including an understanding of the regulatory process.
    data science course
    360DigiTMG

    ReplyDelete
  3. That is it's wise that you ideal research before generating. You possibly can build significantly better post therefore. business software

    ReplyDelete
  4. Thanks for your nice post I really like it and appreciate it. My work is about Custom Vape Cartridge Boxes. If you need perfect quality boxes then you can visit our website.

    ReplyDelete
  5. This is an outstanding post on this blog. I’m happy to see it here. It’s a very helpful and overwhelming little bit of details. It’s wonderful to share this kind of Details!!
    Great post and also Thanks for sharing it!!!
    Gmail pva accounts

    ReplyDelete
  6. Great post with great content, just randomly came here and it amazes me with untapped information Buy Drones in Pakistan

    ReplyDelete
  7. Social media marketing is currently the most important way to express your business to your customers. Due to recent pandemic situation, the world has changed digitally, for this purpose social media accounts are really necessary. And we recommend you to buy Facebook, Instagram, Twitter Pinterest Google accounts from us at very affordable and reasonable price. Thanks. Instagram pva accounts

    ReplyDelete
  8. We sale all types of social media accounts like Instagram Gmail yahoo Facebook Pinterest Twitter telegram number telegram members in good price 100 unique ip accounts aged and fresh accounts are available please visit for more information. Buy instagram pva accounts

    ReplyDelete
  9. ito increase your online business you should start email marketing, we offer you to Buy Gmail PVA Accounts

    ReplyDelete
  10. พีจี เกมสล็อต pg slot ธีมอาหาร น่าเล่น ให้ได้รู้จักกันได้เงินจริง 100% เล่นง่าย ได้เงินไว ต้องที่เว็บเราเท่านั้น ฝากถอนไม่มีขั้นต่ำ PG-SLOT.GAME สล็อตเว็บอันดับ 1 สมัครสมาชิกรับโบนัสทันที!

    ReplyDelete
  11. Here I am again in this page. Thank you for sharing. Content Writing Services in Bhutan.Your content got my attention.

    ReplyDelete
  12. Thanks for sharing the informative post which was very useful
    Web Development Company in India

    ReplyDelete
  13. Herbal Incense C-Liquid offers a relaxing and aromatic experience, perfect for those who value quality and soothing effects. Just as vape culture grows in popularity, products like Herbal Incense C-liquid provide a versatile and enjoyable option for relaxation. Made with premium ingredients, it ensures a smooth and satisfying session without harshness. Its calming properties make it an excellent choice for unwinding after a busy day or setting a peaceful mood. With its clean, consistent performance, this product stands out as a trusted option for anyone looking to elevate their experience with herbal incense alternatives.

    ReplyDelete
  14. Any help that you could give would be much appreciated. I will craft a response blog post from the answers I receive.
    cricut maker black Friday
    cricut sticker ideas
    christmas fonts for cricut
    christmas cricut fonts
    cricut black friday deals

    ReplyDelete
  15. Software design principles focus on clarity, efficiency, and adaptability qualities that also apply when choosing quality herbal products. Just like well-structured code ensures smooth functionality, mad hatter c liquid is crafted for a seamless experience. Its potent blend delivers relaxation while maintaining balance, much like a finely tuned system. Users appreciate its consistency, much like developers value reliable frameworks. Whether enhancing a moment of calm or unwinding after a long day, this product stands out. Finding trusted sources is key, just as in software development quality matters for the best results.

    ReplyDelete