User Tools

Site Tools


iotivity_api_tc_dev_guide

This is an old revision of the document!


General Information

General information section introduces the IoTivity platform and its QA process. Organization of the manual is also shown in this section

Introduction

IoTivity is an open source software framework enabling seamless device-to-device connectivity to address the emerging needs of the Internet of Things. IotivityTest contains the test cases (and related files) for testing the APIs of this IoTivity framework. Currently, there are test cases for Linux, Tizen, Android and Arduino platform.

Organization of the Manual

The user manual consists of five sections: General Information, Coding Convention, Configuration, Folder Structure, Adding Testcases, Build and Run.

  • General Information section explains the purpose of IotivityTest.
  • Configuration section describes installation process of required soft wares for IoTivity Testing.
  • Coding Convention section describe general coding standard for writing testcases.
  • Folder structure section describes how test files are stored in test folder
  • Adding Testcases section will describe how to add testcases for all platform
  • Build section provides the build process of test cases for different platforms
  • Run section provides extra information needed for running TCs

Configuration

Linux PC Configuration

Follow the below link: Linux Platform

Cloning Iotivity Source

To clone the IoTivity Source Code, follow the below link: https://www.iotivity.org/documentation/linux/getting-started

Coding Convention

General Standards

  • DRY - Don't Repeat Yourself
  • Remove an external whitespace

IoTivity Coding Standards

Follow IoTivity Coding Standards:

Python Standards

Follow PEP 8 – Style Guide for Python Code:

Test Case Standards

File Naming Rule:

Naming Format: [Module][Test Objective].[extension]

Example: REResourceBrokerTest.cpp or REResourceBrokerTest.java

Module Names:

Modules Description
CA Connectivity Abstraction
IS IoTivity Simulator
PHY Easy Setup
PM Provisioning Manager
RC Resource Container
RD Resource Directory
RE Resource Encapsulation
RH Resource Hosting
TM Things Manager

Test Suite & Testcase Naming Rule

Test Suite:

For Gtest TC: [Module][Test Objective]_[TC Category]

Example: REResorceBrokerTest_btc

For Junit TC: [Module][Test Objective]

Example: REResorceBrokerTest

TC Category Names:

TC Category Description
btc Basic Test Case
stc Scenario Test Case

Test Case: [Description]_[Design Guide Abbreviation]_[Category]

Example: StartMonitoring_SRC_P

Category Names:

Category Description
P Positive Test Case
N Negative Test Case

Design Guide

Abbreviation Design Guide
RV Representative Value
FSV Formatted Sample Value
RSV Reference Sample Value
EPV Equivalence partitioning Value
LBV Lower Boundary Value
UBV Upper Boundary Value
CLU Complete List Up
PV Partitioning Value
REV Representative Enumeration Value
SRC Success Return Checking
SRCC Success Return Code Checking
GSRV Getter/Setter Validation
SQV Sequential Validation
SCV State Change Validation
CV Callback Validation
VLCC Validation Loop Condition Check
DBCC Dependency Branch Condition Check
STCC State Transition Condition Check
SLCC State Loop Condition Check
CCC Callback Condition Check
CACC Callback Asynchronous Condition Check
LOBV Lower Out of Boundary Value
UOBV Upper Out of Boundary Value
NV Null Value
ESV Empty String Value
USV Unformatted Sample Value
URSV Unformatted Reference Sample Value
ECRC Error Code Return Checking
ETC Exception Throw Checking
VSECC Validation Side Effect Condition Check
DSCC Dependency Skip Condition Check
DICC Dependency Inversion Condition Check
ICCC Invalid Callback Condition Check
USTC Undefined State Transition Check
EG Error Guessing
ALVC Asymmetric Loop Validation Check
ITLC Initial/Terminate Loop Check
STLSEC State Transition Loop Site Effect Check

Examples:

Gtest TC
Example_gtest_tc.c
TEST_F(REResourceBrokerTest_btc, StartMonitoring_SRC_P) {
}
Junit TC
REResourceBrokerTest.java
public class REResourceBrokerTest{
  public void testStartMonitoring_SRC_P() {
  }
}

Android Package Structure:

For test suites: org.iotivity.service.<module>.test.<tctype>

Example: org.iotivity.service.re.test.btc

For helper: org.iotivity.service.<module>.test.helper

Example: org.iotivity.service.re.test.helper

Comments:

CommentRules
/**
* @since describe when this TC has first existed
* @see describe related API or files
* @objective describe a test objective and purpose here
* @target describe a test target
* @test_data describe test data spec
* @pre_condition describe a pre-condition of test case
* @procedure describe a procedure of test case
* @post_condition describe a post condition of test case
* @expected describe an expected result
*/

License Block

Insert a license comment block to every source code file. IoTivity code is licensed under the LICENSE-2.0, the appendix specifies the test to use. You can use the following snippet as a template for C/C++ (SConscript files are Python so use a # as the comment character).

OpenSourceLicense
/* ******************************************************************
 *
 * Copyright 2016 Samsung Electronics All Rights Reserved.
 *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 */

Definitions for Platform

  • Linux: LINUX
  • Tizen: TIZEN
  • Arduino: ARDUINO
  • Windows: WINDOWS

Folder Structure

Adding Test Cases

Adding TC for Linux/Tizen

Adding Test Cases:

Firstly, make sure that there are folders in this below manner [If not available, create necessary folders]- <iotivity>/test/src/tc/<module_name>/gtest/ After that, follow these two tasks-

  1. Add TestSuite: Api testsuites for linux/tizen are stored in the below structured path:~/src/tc/<module_name>/gtest/src/<btc/stc>/<testsuite.cpp>
    1. If there is no previous suite for your module
      1. Create folder src inside gtest folder of your module
      2. You have to create a btc or stc folder inside the src folder of your module
      3. Inside that btc or stc folder, create your testsuite.cpp file
        • Example: ~/src/tc/sm/gtest/src/btc/SMSceneTest.cpp
  2. Add TestCase:
    1. Open a testsuite file
    2. Add a testcase following the gtest framework structure

Using Helper Class:

You can use a helper class for your test cases. Inside the helper class, there will be helper functions. Your testcases will call the helper functions. Those helper function’s will call the module’s APIs.

For using helper class, there are two tasks-

  1. Add Helper Class:
    1. Add Helper Header: Helper class headers are stored in the below structured path: ~/src/tc/<module_name>/gtest/include/<yourhelper.h>
      1. You have to add an include folder inside the gtest folder of your module
      2. Inside that folder, create header file of the helper class
        • Example: ~/src/tc/sm/gtest/include/SMHelper.h
    2. Add Helper CPP: Helper class cpp files are stored in the below structured path: ~/src/tc/<module_name>/gtest/src/helper/<yourhelper.cpp>
      1. You have to add a helper folder inside the src folder of your module
      2. Inside that folder, Create cpp file of the helper class
        • Example: ~/src/tc/sm/gtest/src/helper/SMHelper.cpp
  2. Add Helper Function:
    1. Open helper header file
    2. Add the declaration of the function
    3. Open helper cpp file
    4. Add the definition of the function

N.B After you add tc for a new module, you have to write SConscript for that module, and store the file in the below location:

~/src/build/linux/<YourModulesScons>

Check other module’s SConscript in the above location if necessary

Adding TC for Android

Adding Test Cases:

Firstly, make sure that there are folders in this below manner [If not available, create necessary folders]- <iotivity>/test/src/tc/<module_name>/junit/ After that, follow these two tasks-

  1. Add TestSuite:Api testsuites for android are stored in the below structured path:~/src/tc/<module_name>/junit/src/org/iotivity/service/<module_name>/test/<btc/stc>/<testsuite.java>
    1. If there is no previous suite for your module-
      1. Add a src folder inside junit folder
      2. Inside that src folder, add an android package with name org.iotivity.service.<your module name>.test.<btc/stc>
      3. Add a java class with your testsuite name inside the created package
        • Example: ~/src/tc/tm/junit/src/org/iotivity/service/tm/test/btc/TMManagerTest.java
  2. Add TestCase:
    1. Open a testsuite file.
    2. Add a testcase following the junit framework structure

Using Helper Class:

You can use a helper class for your test cases. Inside the helper class, there will be helper functions. Your testcases will call the helper functions. Those helper function’s will call the module’s APIs.

For using helper class, there are two tasks-

  1. Add Helper Class:
    1. Inside your /junit/src folder, add a package with name org.iotivity.service.<your module name>.test.helper
    2. Add a java helper class with your testsuite name inside the created package
  2. Add Helper Function:
    1. Inside helper.java file, add helper functions

N.B - You have to add build.gradle to add dependencies [library files] of your module. You have to also add AndroidManifest.xml and settings.gradle. You can also add assets folder and keep any extra files there[If needed]. Check other module’s junit folder if necessary.

Adding TC for Arduino

Adding Test Cases:

Firstly, make sure that there are folders in this below manner [If not available, create necessary folders]- <iotivity>/test/src/tc/<module_name>/arduinounit/

After that, follow these two tasks -

  1. Add TestSuite:Api testsuites for arduino are stored in the below structured path: ~/src/tc/<module_name>/arduinounit/src/<btc/stc>/<testsuite.cpp>
    1. If there is no previous suite for your module-
      1. Create folder src inside aruidnounit folder of your module
      2. You have to create a btc or stc folder inside the src folder of your module
      3. Inside that btc or stc folder, create your testsuite.cpp file
        • Example: ~/src/tc/ca/arduinounit/src/btc/CATest.cpp
  2. Add TestCase:
    1. Open a testsuite file
    2. Add a testcase following the arduinounit framework structure

Using Helper Class:

You can use a helper class for your test cases. Inside the helper class, there will be helper functions. Your testcases will call the helper functions. Those helper function’s will call the module’s APIs.

For using helper class, there are two tasks-

  1. Add Helper Class:
    1. Add Helper Header: Helper class headers are stored in the below structured path: ~/src/tc/<module_name>/arduinounit/include/<yourhelper.h>
      1. You have to add an include folder inside the arduinounit folder of your module
      2. Inside that folder, create header file of the helper class
        • Example: ~/src/tc/ca/arduinounit/include/CAHelper.h
    2. Add Helper CPP: Helper class cpp files are stored in the below structured path: ~/src/tc/<module_name>/arduinounit/src/helper/<yourhelper.cpp>
      1. You have to add a helper folder inside the src folder of your module
      2. Inside that folder, Create cpp file of the helper class
        • Example: ~ /src/tc/ca/arduinounit/src/helper/CAHelper.cpp
  2. Add Helper Function:
    1. Open helper header file
    2. Add the declaration of the function
    3. Open helper cpp file
    4. Add the definition of the function

Build

Run

Run

iotivity_api_tc_dev_guide.1518793098.txt.gz · Last modified: 2018/02/16 14:58 by Mats Wichmann