summaryrefslogtreecommitdiffstats
path: root/docs/testing/developer/devguide/unit_tests.rst
blob: 98ed3cecf741065ef8b654840bca6d8fd4ab11df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
.. (c) OPNFV, Dell EMC and others.

==========
Unit Tests
==========

Running from CLI
================

You technically already did when you ran:

.. code-block:: bash

    ci/verify.sh

The shortcut to running the unit tests again from the command line is:

.. code-block:: bash

    source ~/storperf_venv/bin/activate
    nosetests --with-xunit \
          --with-coverage \
          --cover-package=storperf\
          --cover-xml \
          storperf

.. note::

    You must be in the top level storperf directory in order to run the tests.


Set up under LiClipse
=====================

Running the tests:

Right click on the tests folder and select Run as Python Unit Test. Chances
are, you'll get:

.. code-block:: bash

    Traceback (most recent call last):
      File "/home/mark/Documents/EMC/git/opnfv/storperf/storperf/tests/storperf_master_test.py", line 24, in setUp
        self.storperf = StorPerfMaster()
      File "/home/mark/Documents/EMC/git/opnfv/storperf/storperf/storperf_master.py", line 38, in __init__
        template_file = open("storperf/resources/hot/agent-group.yaml")
    IOError: [Errno 2] No such file or directory: 'storperf/resources/hot/agent-group.yaml'

This means we need to set the working directory of the run configuration.

* Under the menu: Run -> Run Configurations:

.. image:: ../images/StorPerf_Tests-Main.jpeg

* Go to the Arguments tab and change the radio button for Working Directory to
  "Default"

.. image:: ../images/StorPerf_Tests-Arguments.jpeg

* And on interpreter tab, change the interpreter to StorPerf:

.. image:: ../images/StorPerf_Tests-Interpreter.jpeg

* Click Apply. From now on, the run should be clean:

.. image:: ../images/StorPerf_Tests-Console.jpeg

|

.. image:: ../images/StorPerf_Tests-PyUnit.jpeg


Adding builtins
===============

For some reason, sqlite needs to be added as a builtin.

* Go to Window -> Preferences, PyDev > Interpreters > Python Interpreter and
  select the StorPerf interpreter:

.. image:: ../images/Python_Interpreters.jpeg

* Go to the Forced Builtins tab, click New and add sqlite3.

.. image:: ../images/Forced_Builtins.jpeg