Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Running Unit Test:

Please follow the steps below:

1) Need to clone from CodeCloud:

    git clone https://gerrit.onap.org/r/optf/has

2) For Environment setup please follow the instruction given in below link:

    HAS Developer Guide

3) For running unit test need to go in terminal look for main directory of the project after that run the command below.

    command: tox

4) On how can we write a test case in Unit test:

   First things need to decide which unit we would like to start with below is an example. 

 below is the code to test:

Image Added

below is the setup first need to test a testcase:

for setup need to import dependency and and class/method that need to be tested

it also differs what is the return value or what is that we want to test. In this case we need to check if it has all the properties when we initiate an instance of a complex class so that we can populate it with further relevant data. In the code blow you might see setup method which is used to set the values before starting any testcase. The setUp() and tearDown() methods allow you to define instructions that will be executed before and after each test method. The  unittest.main() provides a command-line interface to the test script.

Image Added



5) After running it you will see the results as below:

Image Added