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

Reasons for failures


We finished our two tests and we should now examine just how fragile they are. Even though the design of our tests made sense at the time of writing them, they will fail at the slightest provocation. Let's imagine a couple of real-life situations.

The sales team decided that having to change the amount of exclamation marks in the name of the product. These little tweaks happen all the time. We won't change the actual website, but we will change our test to expect a different amount of exclamation marks in the assertion. This will provide a sufficient discrepancy between the test and reality to make the test fail.

Note

You can download the full test code from http://awful-valentine.com/code/chapter-2.

Let's change the assertion in test_add_new_review to look like this:

Running the tests will now give the following output:

Let's do a postmortem of our tests and list several bad mistakes:

  • Test on test dependence: This is the most obvious test. If the first test we execute does...