From the course: AI-Powered Development: GitHub Copilot in Visual Studio Code

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Write unit tests with /test

Write unit tests with /test

Here's the scenario you'll probably hit most often. Your test suite is already set up, your testing framework is in place, and you've just written some new code. Now you want to add a unit test, and that's the perfect use case for the forward slash test command. First, let's look at the created test from the last video. That's this test underscore account dot py file. Because I'm using PyTest, the naming convention for my test files is to start with test underscore. That's so the test runner can find the test. And you can see that's the naming convention here. And all this has is some functions that assert true. So we're going to instead create a unit test for this module. This is the one with the future payment date function. So first thing I need to do is create an empty file with the same naming convention. So this is going to be test underscore payment underscore data. So that matches this file. This is the test file. Then I go over to Copilot, and I make sure that when I have…

Contents