From the course: Software Testing Assistance with GitHub Copilot AI

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Refactor with tests

Refactor with tests

- [Instructor] Refactoring is about making tiny changes that cumulatively improve the code base. You probably already do this by default, identifying tiny issues as you work. Refactoring is an entire discipline. I'm going to focus on four things that make testing easier and make for a cleaner code base. First, identify a brittle function and add tests. This redirect function is responsible for the list of redirects, determining if redirects should take place, on line 13, and finally, returning the redirect. This might require extra mocking initially, and that's okay. The purpose of these initial tests is to lock into place how something works. This prevents you from adding hidden regressions. So I'm going to highlight this and ask Copilot to create tests for that. Now, not only will it create the test, it's going to explain what's being tested. And now I'll just copy this and drop it in our test directory. I'm going to add a new folder for redirects. And pasting in what Copilot came…

Contents