Skip to content

Adding unit testing section #1621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/contribution_and_api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ MAPDL commands mapped to PyMAPDL, see :ref:`ref_mapdl_commands`.
post
solution
xpl
unit_testing
42 changes: 42 additions & 0 deletions doc/source/contribution_and_api/unit_testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. _ref_unit_testing_contributing:

Unit Testing
===============

Unit testing is highly important. It enables to check that the
changes on the code are efficient and don't have an impact on
other parts of the code.

Unit tests are in the ``tests`` directory inside this repository.

Test Validation GitHub workflow
-------------------------------

`Codecov <https://github.com/codecov>`_ generates a coverage report of
the committed code. It details how merging the Pull Request will impact the
coverage. It is one of the checks that must be approved to
merge the code.

Creating a unit test
--------------------

In the pymapdl repository, the tests are done with the **pytest package**.

To create a pytest file, its name must be one of the following forms:
``filename_test.py`` or ``test_filename.py``.

To create tests, please take note of the `pytest documentation <https://docs.pytest.org/en/7.2.x/>`_ .

The `unit test <https://github.com/pyansys/pymapdl/blob/main/tests/test_math.py>`_ of the
**ansys.mapdl.core.math** library is one of the numerous unit tests that you can find in
the `test directory <https://github.com/pyansys/pymapdl/tree/main/tests>`_ .
You'll find examples to understand how you can use the pytest package.