Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit b598aad

Browse files
authored
Adding code coverage for unit tests executed on ArduinoCloudThing source (#18)
* Enable gathering of code coverage data upon execution of unit tests * Extending README with information on how to build and execute the unit tests * Adding badge for showing code coverage
1 parent 2d7ffd1 commit b598aad

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ script:
1111
- cmake ..
1212
- make
1313

14-
after_script:
14+
after_success:
15+
- lcov --directory . --zerocounters
16+
- bin/testArduinoCloudThing
17+
- lcov --directory . --capture --output-file coverage.info
18+
- lcov --remove coverage.info 'test/*' '/usr/*' 'lib/*' --output-file coverage.info
19+
- lcov --list coverage.info
20+
- bash <(curl -s https://codecov.io/bash) -f coverage.info
1521
- cd ..
1622
- rm -rf build
1723

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Arduino Cloud Thing Middleware
22
[![Build Status](https://travis-ci.org/arduino-libraries/ArduinoCloudThing.svg?branch=master)](https://travis-ci.org/arduino-libraries/ArduinoCloudThing)
3+
[![Code Coverage](https://codecov.io/gh/arduino-libraries/ArduinoCloudThing/branch/master/graph/badge.svg)](https://codecov.io/gh/arduino-libraries/ArduinoCloudThing)
34

45
This library contains the implementation of the class ArduinoCloudThing which allows to add **int**, **bool**, **float**, **String** properties which can be read from or written to the cloud. To achieve this goal ArduinoCloudThing possesses functions for encoding and decoding CBOR (Concise Binary Object Representation) encoded data which is used to transfer the properties value between a **thing** and the **cloud**.
56

@@ -53,3 +54,13 @@ thing.addProperty(int_property, "test_int_property", Permission::ReadWrite).publ
5354
* **decode** decodes a CBOR buffer received from the cloud and updates writeable properties accordingly. Also the update callbacks are called, if the value of a property has changed.
5455

5556
`decode(uint8_t const * const data, size_t const length)`
57+
58+
## Unit Tests
59+
60+
The code of `ArduinoCloudThing` is verified via unit tests which are build and executed by the Travis CI system after every commit. However, one can also build and execute the unit tests manually using the following steps:
61+
```bash
62+
cd test && mkdir build && cd build
63+
cmake ..
64+
make -j4
65+
bin/testArduinoCloudThing
66+
```

test/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,3 @@ add_executable(
5353

5454
##########################################################################
5555

56-
add_custom_command(TARGET ${TEST_TARGET} POST_BUILD
57-
COMMENT "Exeuting unit tests ..."
58-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
59-
COMMAND lcov --directory . --zerocounters
60-
COMMAND bin/${TEST_TARGET}
61-
COMMAND lcov --directory . --capture --output-file coverage.info
62-
COMMAND lcov --remove coverage.info 'test/*' '/usr/*' 'lib/*' --output-file coverage.info
63-
COMMAND lcov --list coverage.info
64-
)
65-
66-
##########################################################################
67-

0 commit comments

Comments
 (0)