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.
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 | YouTube | LinkedIn | Articles
19 comments:
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.
It is the intent to provide valuable information and best practices, including an understanding of the regulatory process.
data science course
360DigiTMG
That is it's wise that you ideal research before generating. You possibly can build significantly better post therefore. business software
web development uk web development ukraine web development uk companies web development uk forum web development courses uk web development jobs uk
seo in uk seo service best seo ranking
ui design uk ui design service uk ui design course uk
Thanks for sharing useful information.
web designing training in chennai
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.
I simply couldn't resist praising the way you play with words. This is a perfect example of a well-written blog post.
vé máy bay vietjet đi phú yên
ve may bay di singapore
vé máy bay từ sài gòn đi thái lan
giá vé việt nam malyasia
săn vé máy bay đi úc giá rẻ
vé máy bay đi hàn quốc hạng thương gia
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
I appreciate your post thanks for sharing the information.
Display boxes Alaska
Branding Mailer boxes
Great post I like it very much keep up the good work.
Cell Phone box company
bulk Candle Boxes
Great post with great content, just randomly came here and it amazes me with untapped information Buy Drones in Pakistan
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
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
ito increase your online business you should start email marketing, we offer you to Buy Gmail PVA Accounts
พีจี เกมสล็อต pg slot ธีมอาหาร น่าเล่น ให้ได้รู้จักกันได้เงินจริง 100% เล่นง่าย ได้เงินไว ต้องที่เว็บเราเท่านั้น ฝากถอนไม่มีขั้นต่ำ PG-SLOT.GAME สล็อตเว็บอันดับ 1 สมัครสมาชิกรับโบนัสทันที!
very informative blog..for more info visit power app development
Loved reading this, thank you
Here I am again in this page. Thank you for sharing. Content Writing Services in Bhutan.Your content got my attention.
Thanks for sharing the informative post which was very useful
Web Development Company in India
Post a Comment