Merge "Print stack when catching exceptions in run_tests.py"
[functest.git] / docs / testing / developer / internship / unit_tests / index.rst
1 =======
2 License
3 =======
4
5 Functest Docs are licensed under a Creative Commons Attribution 4.0
6 International License.
7 You should have received a copy of the license along with this.
8 If not, see <http://creativecommons.org/licenses/by/4.0/>.
9
10 ===================
11 Functest Unit tests
12 ===================
13
14 Author: Ashish Kumar
15 Mentors: H.Yao, J.Lausuch, M.Richomme
16
17 Abstract
18 ========
19
20
21 Version history
22 ===============
23
24 +------------+----------+------------------+------------------------+
25 | **Date**   | **Ver.** | **Author**       | **Comment**            |
26 |            |          |                  |                        |
27 +------------+----------+------------------+------------------------+
28 | 2016-11-14 | 0.0.1    | Morgan Richomme  | Beginning of the       |
29 |            |          | (Orange)         | Internship             |
30 +------------+----------+------------------+------------------------+
31 | 2017-03-31 | 0.0.2    | Ashish Kumar     | During the             |
32 |            |          | (IIIT Hyderabad) | Internship             |
33 +------------+----------+------------------+------------------------+
34
35
36 Overview:
37 =========
38 Functest project is developing and integrating functional test cases for OPNFV
39 and it is part of OPNFV since the beginning. Functest develops its own testcases
40 and framework. This framework includes several utility libraries. The Project is
41 growing rapidly with more features, tests added as per requirement. It becomes
42 the responsibility of every developer to maintain the integrity of code i.e. new
43 patch should not break the previous functionality of the project. To automate this
44 process of software development, we should write unit tests and add them to CI so
45 that when a new patch is ready to merge, we shouldn't allow those which are breaking
46 previous unit tests or decreasing the coverage.
47
48
49
50 Problem Statement:
51 ------------------
52 The goal of the intership consists in creating unit test suites on Functest code
53 with good code coverage (>80%) and integrate it in continuous integration in order
54 to consolidate existing code.
55
56
57 Curation Phase
58 --------------
59 The curation phase was the first 3 to 4 weeks of the internship. This phase was to get
60 familiar with the functest code and functionality and explore the solutions for unit
61 testing in other projects and come up with the strategy for writing unit tests in functest.
62
63 In this phase we decided,
64 - Coverage should be 80%. There are some functions like __init__, getter, setter and other
65   private methods for which writing unit test is a tedious job, so we are leaving these methods
66   for now.
67 - Do method wise testing for every module.
68 - Use mock for external or third party services, system calls and other external library calls
69   which could impact the behaviour of system during the run of unit test.
70 - Add it in jenkins as passing criteria for patches.
71 - Write tests in modular way so that it can help to serve as a form of documentation.
72
73
74
75 Schedule:
76 =========
77 +--------------------------+------------------------------------------+
78 | **Date**                 | **Comment**                              |
79 |                          |                                          |
80 +--------------------------+------------------------------------------+
81 | Nov 14th - Nov 28th      | 1. Learn Functest Project Business       |
82 |                          | 2. Set up the development environment    |
83 |                          | 3. Run Functest code                     |
84 +--------------------------+------------------------------------------+
85 | Nov 28th  -  Dec.9th     | 1. Explore Unit Testing Strategy,        |
86 |                          | 2. Learn about Mock in python            |
87 +--------------------------+------------------------------------------+
88 | Dec 12th - Dec 23rd      | Implement Unit Tests for CLI             |
89 |                          |                                          |
90 +--------------------------+------------------------------------------+
91 | Dec 26th   - Jan 6th     | Implement Unit Tests for Utils           |
92 |                          |                                          |
93 +--------------------------+------------------------------------------+
94 | Jan 9th -  Jan 20th      | Implement Unit Tests for CI              |
95 |                          |                                          |
96 +--------------------------+------------------------------------------+
97 | Jan 23rd - Feb 3rd       | Implement Unit Tests for Core            |
98 |                          |                                          |
99 +--------------------------+------------------------------------------+
100 | Feb 6th  - Feb 17th      | Implement Unit Tests for                 |
101 |                          | opnfv_tests/openstack/tempest            |
102 +--------------------------+------------------------------------------+
103 | Feb 20th  - Mar 3rd      | Implement Unit Tests for                 |
104 |                          | opnfv_tests/openstack/rally              |
105 +--------------------------+------------------------------------------+
106 | Mar 6th  - Mar 17th      | Implement Unit Tests for                 |
107 |                          | opnfv_tests/vnf/ims                      |
108 +--------------------------+------------------------------------------+
109 | Mar 20th  - Mar 31st     | Recheck and Increase Coverage for all    |
110 |                          | modules > 80%                            |
111 +--------------------------+------------------------------------------+
112 | Apr 3rd  -  Apr 14th     | Add CI Gating for unit tests             |
113 |                          |                                          |
114 +--------------------------+------------------------------------------+
115 | Apr 17th  -  Apr 28th    | Use Tox Utility, Documentation           |
116 |                          |                                          |
117 +--------------------------+------------------------------------------+
118 | Apr 28th  -  End         | Bug Fixing                               |
119 |                          |                                          |
120 +--------------------------+------------------------------------------+
121
122
123 References:
124 ===========
125
126 .. _`[1]` : https://wiki.opnfv.org/display/DEV/Intern+Project%3A+Functest+unit+tests