<commit_before>.. _testing:

Testing
=======

Unit Tests
----------

Writing unit tests for registered features and commands are easy and you don't
have to mock the whole language server. If you skipped advanced usage page,
take a look at :ref:`passing language server instance <passing-instance>`
section for more details.

Json Extension example's `unit tests`_ might be helpful.

Integration Tests
-----------------


.. _unit tests: https://github.com/openlawlibrary/pygls/blob/master/examples/json-extension/server/tests/unit<commit_msg>Add integration testing section to testing docs page<commit_after>.. _testing:

Testing
=======

Unit Tests
----------

Writing unit tests for registered features and commands are easy and you don't
have to mock the whole language server. If you skipped advanced usage page,
take a look at :ref:`passing language server instance <passing-instance>`
section for more details.

Json Extension example's `unit tests`_ might be helpful.

Integration Tests
-----------------

Integration tests cover include the whole flow, from sending the client
request, to getting the result from the server.
Since *Language Server Protocol* defines bidirectional communication between
the client and the server, we used *pygls* to simulate the client and send
desired requests to the server. To get better understanding of how setup it,
take a look at our test `fixtures`_.


.. _unit tests: https://github.com/openlawlibrary/pygls/blob/master/examples/json-extension/server/tests/unit
.. _fixtures: https://github.com/openlawlibrary/pygls/blob/master/tests/conftest.py#L29
{'fraction_non_alphanumeric': 0.10763454317897372, 'fraction_numerical': 0.0012515644555694619, 'mean_word_length': 4.028301886792453, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '217316', 'n_tokens_mistral': 425, 'n_tokens_neox': 404, 'n_words': 183}