• Home
  • Public Speaking
  • Travel

Run PyTest in VS Code


1. Create Tests

After tests are implemented, we will run them. For this purpose, they have to be discovered as tests. By default, it is configured to find methods starting by “test_” are regarded as test cases. But this can be customized.

2. Enable Test Framework

The framework that we use should be enabled to trigger test cases. (either unittest or pytest) On VSCode, this can be done over Command Palette (Ctrl + Shift + P): Python Configure Tests

3. Discover Tests

This can be done over Command Palette (Ctrl + Shift + P): Python Discover Tests

4. Run/Debug

We can run or debug: Console outputs are not captured by default. (We should trigger over cmd line with -s parameters to capture all)

For running pytest with fixtures, check: PyTest Fixtures