Book Image

Selenium Design Patterns and Best Practices

By : Dima Kovalenko
Book Image

Selenium Design Patterns and Best Practices

By: Dima Kovalenko

Overview of this book

Table of Contents (18 chapters)
Selenium Design Patterns and Best Practices
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Refactoring tests


Since this chapter will be focused on refactoring tests, let's first define this term. Refactoring is the act of restructuring your code to improve the internal efficiency, stability, and long-term maintainability without adding or modifying any of the underlying functionalities. At the end of the refactoring session, we should not have any new tests; the only goal is to improve the existing tests.

Since there are no obvious instant results such as having 10 more new tests, refactoring may seem like a waste of time. However, having two tests that do not randomly fail is a lot more productive in the long run than having 12 tests that cannot be relied on. Refactoring your tests is similar to calisthenics; if you don't exercise, you will probably die of a heart attack 20 years before your time. That being said, we will not add any new tests in this chapter. Instead, we will improve the product review tests in Chapter 2, The Spaghetti Pattern.