To test your code for extracting numbers from files, you can create sample files containing different types of numbers and test your code on them. You can also use the built-in Python `unittest` module to automate your tests.