In this example, the function accepts any string and returns true if that string contains a properly formatted account number, false otherwise. Unit tests are concerned only with the unit's interface-its arguments and return values-not with its implementation (which is why no code is shown here in the function body often you'd be using other well-tested libraries to help implement the function). Unit tests are then other pieces of code that specifically exercise the code unit with a full range of different inputs, including boundary and edge cases.įor example, say you have a function to validate the format of an account number that a user enters in a web form: def validate_account_number_format ( account_string ): # Return False if invalid, True if valid #. (If you're already familiar with unit testing, you can skip to the walkthroughs.)Ī unit is a specific piece of code to be tested, such as a function or a class. The Python extension supports testing with Python's built-in unittest framework and pytest. Configure IntelliSense for cross-compilingĮdit Python testing in Visual Studio Code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |