Skip to content

Instantly share code, notes, and snippets.

@schuster-rainer
Created June 7, 2012 20:46
Show Gist options
  • Save schuster-rainer/2891441 to your computer and use it in GitHub Desktop.
Save schuster-rainer/2891441 to your computer and use it in GitHub Desktop.
python test discovery from commandline and visual studio 2010
# Projekt Structure
- project_root
|
+ doc/
+ src/
+ tests/
+ run_tests.bat
# Setup
simply put the run_tests.bat in the root_folder of your projekt and execute it.
for details on how to configure test discovery have a look at the documentation: http://docs.python.org/library/unittest.html#test-discovery
# Visual Studio 2010
in order to use it with python tools for visual studio goto
Tools > External Tools
add an entry with the following settings:
+------------------------------------------------------+
| Title : python unittest |
+------------------------------------------------------+
| Command : $(SolutionDir)\run_tests.bat |
+------------------------------------------------------+
| Arguments: --verbose -p "*test*.py" |
+------------------------------------------------------+
| Initial Directory: $(SolutionDir) |
+------------------------------------------------------+
set PYTHONPATH=%~dp0\src
rem use unittest if your python version > 2.7 and unittest2 if you installed a backport running in python 2.5 or 2.6
python -m unittest2 discover %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment