Reputation: 23
I want to create automation tests for web application with Visual Studio code, Python and unittest. However my Test Explorer fails to discover tests (no error appears it is just empty).
Despite that i have needed extensions (Python, Test Explorer UI and Python Test Explorer), prepared settings.json and required methods' and classes' decoration, commands like run all tests or discover doesn't work out. However debugging whole file actually runs tests (i see output in terminal).
CODE:
import unittest
class testClass(unittest.TestCase):
def test_method(self):
self.assertEqual(1, 1)
def test_method2(self):
self.assertEqual(1, 2)
if __name__ == '__main__':
unittest.main()
SETTINGS:
{
"testExplorer.showOnRun": true,
"python.testing.unittestEnabled": true,
"python.testing.pyTestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.pythonPath": "C:\\Users\\Cezary\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe"
}
Upvotes: 2
Views: 2364
Reputation: 1909
List of things to consider:
test_
.python -m unittest discover
in your project root directory. If that does not find your tests, VSCode won't find them either.__init__.py
files)Upvotes: 1