In this video, Meaghan Lewis shares principles to follow in order to create tests that are reusable and maintainable. Meaghan extracts methods from the test to make it cleaner and easier to read.
- [Instructor] There are just a couple more extractions…I want to make in order to make the test cleaner…and easier to read.…Looking through the test again,…I notice that there are multiple actions that are repeated.…Those actions are finding the element…and sending the keys to that element.…So what I will do here is to break up these actions…into methods in order to make my test…more readable and reusable.…I'll start by focusing on where we enter the user name…and define a method to enter the user name.…
This method will take in a user name parameter.…And in the body of the method, I will paste the two lines…that enter the user name.…Now, on lines 22 and 23, I can replace these…with the name of the method and call that here,…passing in the username parameter.…Next I'm going to move on and extract these two lines…into a method called enter_email,…which will take in an email as a parameter.…
And in the body of this method, I will paste those two lines…that enter the email, and then I can go and replace them…by calling the method enter_email here,…
Find out how to set up the test-writing framework, WebDriver, and Selenium Grid, which allows you to distribute the testing load and run tests against a remote server. Learn best practices to write effective tests using variables and functions, and to organize tests into suites that can scale over time. Instructor Meaghan Lewis—a QA engineer at GitHub—also explains the test pyramid paradigm, which details an ideal way to balance unit, integration, and UI testing.
- Setting up Selenium WebDriver
- Using the Selenium grid to distribute the testing load
- Setting up a hub and nodes
- Writing clean test code
- Organizing a test suite