From the course: Software Testing Assistance with GitHub Copilot AI

Unlock the full course today

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

Code quality

Code quality

- [Narrator] Tested code is higher quality code. The act of writing tests forces you to think through execution paths and simplify logic. I'm starting with the branch from chapter two, video three. This is the original logic for dealing with redirects. And at a glance it's mostly fine. It works. It only works with a specific array structure and get params aren't handled. Now I'm going to jump to branch chapter four, video one. And this was the final state I left this redirect file in. Previously it was 43 lines. Now it's only 46, so not a ton more. I'm going to call some parts out. First, there's this function should redirect that returns a bull that tells whether we should or shouldn't redirect. Then there's a redirect value that returns the value of the redirect. Both have repetitive logic, but the thing I really want to call attention to here are the tests. For a moment, ignore what this does and think through new developer experience. In the original, the logic was direct, but…

Contents