Functional Test Refactoring: Extract Function

Extract a set of test steps performing a common user operation to a reusable function

Zhimin Zhan
Geek Culture
Published in
4 min readMar 18, 2021

--

This is the 1st of 6 Functional Test Refactorings: Extract Function. I will show each refactoring in the following sections:

  • Motivation, Why?
  • Mechanics, How?
  • Refactoring Steps, step by step in TestWise IDE
  • Sample test scripts (before and after)
  • Demonstration (animated GIF, easier to follow the core steps)
  • Demonstration (video, easier to get a flow of actions)
  • Benefits
  • Exercises

You may start with any section.

I strongly recommend you doing this refactoring exercise (the one demonstrated and extras). Once you have mastered the concept, performing refactorings is quick, usually in seconds. To help you get into action quickly, I prepared the test project on Github (available for free).

> cd my-working-dir
> git clone https://github.com/testwisely/agiletravel-ui-tests

The test project is at my-working-dir/agiletravel-ui-tests/pre-refactoring .

--

--

Zhimin Zhan
Geek Culture

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.