<type>documentation</type>
<domain>testing</domain>
<id>testing</id>
<title>Unit Testing</title>
<date>$Date: 2006-05-24 22:53:07 -0400 (Wed, 24 May 2006) $</date>
<version>$Revision: 13098 $</version>
<product>pro+</product>

Wing Pro's `Testing <script:show_panel#panel_type="testing">`__ tool provides
a convenient way to run and debug unit tests written using the standard
library's ``unittest`` and ``doctest`` modules, ``pytest``, ``nose``, and the Django
testing framework.

**Adding Tests**

Tests are added from the ``Testing`` menu, with ``Add Single File`` and ``Add Current
File`` to add individual files, or with ``Add Files from Project`` to apply a filter to
the set of all files in the project. For details, see `Project Test Files
<ref:testing/proj>`__.

The testing framework used to run files is selected with `Default Test Framework
<script:view_project_properties#highlighted_attrib="testing.test-framework">`__ under the
``Testing`` tab of `Project Properties <ref:proj/project-properties>`__ or with
``Test Framework`` under the ``Testing`` tab of `File Properties
<ref:proj/file-properties>`__ for individual test files.

**Running Tests**

To run tests, press the ``Run Tests`` button in the Testing tool, or use one of the items
in the ``Testing`` menu. For details, see `Running and Debugging Tests
<ref:testing/running>`__.

While tests are running, the ``Testing`` tool updates to indicate the status of the run.
After the tests have finished running, the status icon for each test will change to
indicate the result of the run:

|pass| indicates the test passed

|fail| indicates the test failed

|skip| indicates the test was skipped

|unknown| indicates the test was not run or did not complete

.. |pass| image:: icon:wingide-test-pass
  :class: inline-image
.. |fail| image:: icon:wingide-test-fail
  :class: inline-image
.. |skip| image:: icon:wingide-test-skip
  :class: inline-image
.. |unknown| image:: icon:wingide-test-unknown
  :class: inline-image

**Viewing Test Results**

Individual tests may be expanded to show output generated by the test or any exception
that occurred. Exceptions, including any `PEP 3134 <https://www.python.org/dev/peps/pep-3134/>`__ 
chained exceptions, may be expanded to display tracebacks.

``Collapse All Tests`` and ``Expand All Failed Tests`` in the right-click context menu in
the ``Testing`` tool can be used to quickly hide all test details, or show details only
for failed tests.

Double-click on any test or use ``Goto Source`` in the right-click context menu in
the ``Testing`` tool to display the source code for the test in the editor.

To focus on a subset of the test files, enter a fragment matching those test file names
into the ``File Filter`` field in the ``Testing`` tool. Restore the field to blank
redisplays the entire lists of tests.

Output shown for tests may optionally be wrapped to fit the display by checking the ``Wrap
Output Lines`` item in the right-click context menu on the ``Testing`` tool.
