Allow running tests individually
If there is a non-zero number of arguments, run_tests.sh now passes through the arguments to `manage.py test`, skipping the default horizon/openstack_dashboard suites. The correct settings module is chosen based on the first module given in the argument. E.g., horizon.test.tests.tables chooses the horizon.test.settings module. Change-Id: I5321e87bec6831fb7574e045a82de06086b1d0d0
This commit is contained in:
parent
0e328995ec
commit
16fd3c9ebb
@ -43,6 +43,25 @@ tests by using the ``--skip-selenium`` flag::
|
|||||||
This isn't recommended, but can be a timesaver when you only need to run
|
This isn't recommended, but can be a timesaver when you only need to run
|
||||||
the code tests and not the frontend tests during development.
|
the code tests and not the frontend tests during development.
|
||||||
|
|
||||||
|
Running a subset of tests
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Instead of running all tests, you can specify an individual directory, file,
|
||||||
|
class, or method that contains test code.
|
||||||
|
|
||||||
|
To run the tests in the ``horizon/test/tests/tables.py`` file::
|
||||||
|
|
||||||
|
./run_tests.sh horizon.test.tests.tables
|
||||||
|
|
||||||
|
To run the tests in the `WorkflowsTests` class in
|
||||||
|
``horizon/test/tests/workflows``::
|
||||||
|
|
||||||
|
./run_tests.sh horizon.test.tests.workflows:WorkflowsTests
|
||||||
|
|
||||||
|
To run just the `WorkflowsTests.test_workflow_view` test method::
|
||||||
|
|
||||||
|
./run_tests.sh horizon.test.tests.workflows:WorkflowsTests.test_workflow_view
|
||||||
|
|
||||||
Using Dashboard and Panel Templates
|
Using Dashboard and Panel Templates
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ before you submit any pull requests/patches.
|
|||||||
To run the tests::
|
To run the tests::
|
||||||
|
|
||||||
$ ./run_tests.sh
|
$ ./run_tests.sh
|
||||||
|
|
||||||
|
It's also possible to :doc:`run a subset of unit tests<ref/run_tests>`.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
0
openstack_dashboard/test/tests/__init__.py
Normal file
0
openstack_dashboard/test/tests/__init__.py
Normal file
23
run_tests.sh
23
run_tests.sh
@ -69,6 +69,7 @@ restore_env=0
|
|||||||
runserver=0
|
runserver=0
|
||||||
only_selenium=0
|
only_selenium=0
|
||||||
with_selenium=0
|
with_selenium=0
|
||||||
|
testopts=""
|
||||||
testargs=""
|
testargs=""
|
||||||
with_coverage=0
|
with_coverage=0
|
||||||
makemessages=0
|
makemessages=0
|
||||||
@ -99,17 +100,18 @@ function process_option {
|
|||||||
--backup-environment) backup_env=1;;
|
--backup-environment) backup_env=1;;
|
||||||
--restore-environment) restore_env=1;;
|
--restore-environment) restore_env=1;;
|
||||||
--destroy-environment) destroy=1;;
|
--destroy-environment) destroy=1;;
|
||||||
|
-*) testopts="$testopts $1";;
|
||||||
*) testargs="$testargs $1"
|
*) testargs="$testargs $1"
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_management_command {
|
function run_management_command {
|
||||||
${command_wrapper} python $root/manage.py $testargs
|
${command_wrapper} python $root/manage.py $testopts $testargs
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_server {
|
function run_server {
|
||||||
echo "Starting Django development server..."
|
echo "Starting Django development server..."
|
||||||
${command_wrapper} python $root/manage.py runserver $testargs
|
${command_wrapper} python $root/manage.py runserver $testopts $testargs
|
||||||
echo "Server stopped."
|
echo "Server stopped."
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,13 +274,26 @@ function run_tests {
|
|||||||
export SKIP_UNITTESTS=1
|
export SKIP_UNITTESTS=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$testargs" ]; then
|
||||||
|
run_tests_all
|
||||||
|
else
|
||||||
|
run_tests_subset
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_tests_subset {
|
||||||
|
project=`echo $testargs | awk -F. '{print $1}'`
|
||||||
|
${command_wrapper} python $root/manage.py test --settings=$project.test.settings $testopts $testargs
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_tests_all {
|
||||||
echo "Running Horizon application tests"
|
echo "Running Horizon application tests"
|
||||||
export NOSE_XUNIT_FILE=horizon/nosetests.xml
|
export NOSE_XUNIT_FILE=horizon/nosetests.xml
|
||||||
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then
|
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then
|
||||||
export NOSE_HTML_OUT_FILE='horizon_nose_results.html'
|
export NOSE_HTML_OUT_FILE='horizon_nose_results.html'
|
||||||
fi
|
fi
|
||||||
${command_wrapper} coverage erase
|
${command_wrapper} coverage erase
|
||||||
${command_wrapper} coverage run -p $root/manage.py test horizon --settings=horizon.test.settings $testargs
|
${command_wrapper} coverage run -p $root/manage.py test horizon --settings=horizon.test.settings $testopts
|
||||||
# get results of the Horizon tests
|
# get results of the Horizon tests
|
||||||
HORIZON_RESULT=$?
|
HORIZON_RESULT=$?
|
||||||
|
|
||||||
@ -287,7 +302,7 @@ function run_tests {
|
|||||||
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then
|
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then
|
||||||
export NOSE_HTML_OUT_FILE='dashboard_nose_results.html'
|
export NOSE_HTML_OUT_FILE='dashboard_nose_results.html'
|
||||||
fi
|
fi
|
||||||
${command_wrapper} coverage run -p $root/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings $testargs
|
${command_wrapper} coverage run -p $root/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings $testopts
|
||||||
# get results of the openstack_dashboard tests
|
# get results of the openstack_dashboard tests
|
||||||
DASHBOARD_RESULT=$?
|
DASHBOARD_RESULT=$?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user