summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-07-30 17:02:28 +0200
committerChristophe Simonis <chs@odoo.com>2018-07-30 17:02:28 +0200
commita719cf256364c35229ac1695e9011870616bcce4 (patch)
tree2af64c5818e3732d6d6f534eae6b7ed5d8a873f6 /doc/reference
parent25de4a542679893066feb978dd4d8e731cbe495f (diff)
parentb4555df336d05481de3077f3513a34b315f39bce (diff)
[MERGE] forward port branch saas-11.3 up to b4555df336d
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/cmdline.rst11
-rw-r--r--doc/reference/security.rst2
-rw-r--r--doc/reference/testing.rst145
3 files changed, 155 insertions, 3 deletions
diff --git a/doc/reference/cmdline.rst b/doc/reference/cmdline.rst
index 058eac51ddd..c239262e377 100644
--- a/doc/reference/cmdline.rst
+++ b/doc/reference/cmdline.rst
@@ -113,6 +113,10 @@ Running the server
runs tests after installing modules
+.. option:: --test-tags 'tag_1,tag_2,...,-tag_n'
+
+ select the tests to run by using tags.
+
.. option:: --dev <feature,feature,...,feature>
* ``all``: all the features below are activated
@@ -305,6 +309,13 @@ customize the amount of logging output
enables `log rotation <https://docs.python.org/2/library/logging.handlers.html#timedrotatingfilehandler>`_
daily, keeping 30 backups. Log rotation frequency and number of backups is
not configurable.
+
+ .. danger::
+
+ Built-in log rotation is not reliable in multi-workers scenarios
+ and may incur significant data loss. It is *strongly recommended* to
+ use an external log rotation utility or use system loggers (--syslog)
+ instead.
.. option:: --syslog
diff --git a/doc/reference/security.rst b/doc/reference/security.rst
index bacb02c787f..fd6402893c3 100644
--- a/doc/reference/security.rst
+++ b/doc/reference/security.rst
@@ -71,8 +71,6 @@ This means the first *group rule* restricts access, but any further
.. warning:: record rules do not apply to the Administrator user
:class: aphorism
- although access rules do
-
.. _reference/security/fields:
Field Access
diff --git a/doc/reference/testing.rst b/doc/reference/testing.rst
index e25e8d31433..d14b3c25838 100644
--- a/doc/reference/testing.rst
+++ b/doc/reference/testing.rst
@@ -64,6 +64,8 @@ related to testing Odoo content (modules, mainly):
.. autoclass:: odoo.tests.common.HttpCase
:members: browse_ref, ref, url_open, phantom_js
+.. autofunction:: odoo.tests.common.tagged
+
By default, tests are run once right after the corresponding module has been
installed. Test cases can also be configured to run after all modules have
been installed, and not run right after the module installation:
@@ -111,6 +113,147 @@ supported.
.. _unittest documentation: https://docs.python.org/2/library/unittest.html
+Test selection
+--------------
+
+In Odoo, Python tests can be tagged to facilitate the test selection when
+running tests.
+
+Subclasses of :class:`odoo.tests.common.BaseCase` (usually through
+:class:`~odoo.tests.common.TransactionCase`,
+:class:`~odoo.tests.common.SavepointCase` or
+:class:`~odoo.tests.common.HttpCase`) are automatically tagged with
+``standard``, ``at_install`` and their source module's name by default.
+
+Invocation
+^^^^^^^^^^
+
+:option:`--test-tags <odoo-bin --test-tags>` can be used to select/filter tests
+to run on the command-line.
+
+This option defaults to ``+standard`` meaning tests tagged ``standard``
+(explicitly or implicitly) will be run by default when starting Odoo
+with :option:`--test-enable <odoo-bin --test-enable>`.
+
+When writing tests, the :func:`~odoo.tests.common.tagged` decorator can be
+used on **test classes** to add or remove tags.
+
+The decorator's arguments are tag names, as strings.
+
+.. danger:: :func:`~odoo.tests.common.tagged` is a class decorator, it has no
+ effect on functions or methods
+
+Tags can be prefixed with the minus (``-``) sign, to *remove* them instead of
+add or select them e.g. if you don't want your test to be executed by
+default you can remove the ``standard`` tag:
+
+.. code-block:: python
+
+ from odoo.tests import TransactionCase, tagged
+
+ @tagged('-standard', 'nice')
+ class NiceTest(TransactionCase):
+ ...
+
+This test will not be selected by default, to run it the relevant tag will
+have to be selected explicitely:
+
+.. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags nice
+
+Note that only the tests tagged ``nice`` are going to be executed. To run
+*both* ``nice`` and ``standard`` tests, provide multiple values to
+:option:`--test-tags <odoo-bin --test-tags>`: on the command-line, values
+are *additive* (you're selecting all tests with *any* of the specified tags)
+
+.. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags nice,standard
+
+The config switch parameter also accepts the ``+`` and ``-`` prefixes. The
+``+`` prefix is implied and therefore, totaly optional. The ``-`` (minus)
+prefix is made to deselect tests tagged with the prefixed tags, even if they
+are selected by other specified tags e.g. if there are ``standard`` tests which
+are also tagged as ``slow`` you can run all standard tests *except* the slow
+ones:
+
+.. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags 'standard,-slow'
+
+When you write a test that does not inherit from the
+:class:`~odoo.tests.common.BaseCase`, this test will not have the default tags,
+you have to add them explicitely to have the test included in the default test
+suite. This is a common issue when using a simple ``unittest.TestCase`` as
+they're not going to get run:
+
+.. code-block:: python
+
+ import unittest
+ from odoo.tests import tagged
+
+ @tagged('standard', 'at_install')
+ class SmallTest(unittest.TestCase):
+ ...
+
+Special tags
+^^^^^^^^^^^^
+
+- ``standard``: All Odoo tests that inherit from
+ :class:`~odoo.tests.common.BaseCase` are implicitely tagged standard.
+ :option:`--test-tags <odoo-bin --test-tags>` also defaults to ``standard``.
+
+ That means untagged test will be executed by default when tests are enabled.
+- ``at_install``: Means that the test will be executed right after the module
+ installation and before other modules are installed. This is a default
+ implicit tag.
+- ``post_install``: Means that the test will be executed after all the modules
+ are installed. This is what you want for HttpCase tests most of the time.
+
+ Note that this is *not exclusive* with ``at_install``, however since you
+ will generally not want both ``post_install`` is usually paired with
+ ``-at_install`` when tagging a test class.
+- *module_name*: Odoo tests classes extending
+ :class:`~odoo.tests.common.BaseCase` are implicitely tagged with the
+ technical name of their module. This allows easily selecting or excluding
+ specific modules when testing e.g. if you want to only run tests from
+ ``stock_account``:
+
+ .. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags stock_account
+
+Examples
+^^^^^^^^
+
+.. important::
+
+ Tests will be executed only in the installed or updated modules. So
+ modules have to be selected with the :option:`-u <odoo-bin -u>` or
+ :option:`-i <odoo-bin -i>` switches. For simplicity, those switches are
+ not specified in the examples below.
+
+Run only the tests from the sale module:
+
+.. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags sale
+
+Run the tests from the sale module but not the ones tagged as slow:
+
+.. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags 'sale,-slow'
+
+Run only the tests from stock or tagged as slow:
+
+.. code-block:: console
+
+ $ odoo-bin --test-enable --test-tags '-standard, slow, stock'
+
+.. note:: ``-standard`` is implicit (not required), and present for clarity
+
Testing JS code
===============
@@ -153,4 +296,4 @@ that the web client and the server work together. In order to do that, we can
write another kind of test: tours. A tour is a mini scenario of some interesting
business flow. It explains a sequence of steps that should be followed. The
test runner will then create a phantom_js browser, point it to the proper url
-and simulate the click and inputs, according to the scenario. \ No newline at end of file
+and simulate the click and inputs, according to the scenario.