|
21 | 21 | * [Mock command line examples](#mock-command-line-examples) |
22 | 22 | * [Mocking example with Freescale K64F platform](#mocking-example-with-freescale-k64f-platform) |
23 | 23 | * [mbed-ls unit testing](#mbed-ls-unit-testing) |
| 24 | + * [Code coverage](#code-coverage) |
24 | 25 | * [Configure mbed-enabled device to work with your host](#configure-mbed-enabled-device-to-work-with-your-host) |
25 | 26 | * [Windows serial port configuration](#windows-serial-port-configuration) |
26 | 27 | * [Mounting with sync](#mounting-with-sync) |
@@ -528,6 +529,37 @@ Ran 18 tests in 0.302s |
528 | 529 | OK |
529 | 530 | ``` |
530 | 531 |
|
| 532 | +## Code coverage |
| 533 | + |
| 534 | +We can measure code coverage for unit tests deployed together with ```mbed-ls```. To do so we can use popular Python ```coverage``` tools. |
| 535 | +First install ```coverage``` tool on your system: |
| 536 | +``` |
| 537 | +$ pip install coverage --upgrade |
| 538 | +``` |
| 539 | + |
| 540 | +Next go to ```mbed-ls``` local directory and execute coverage for unit tests: |
| 541 | +``` |
| 542 | +$ cd mbed-ls |
| 543 | +$ coverage run setup.py test |
| 544 | +``` |
| 545 | + |
| 546 | +Above command will execute test cases and will grab code coverage numbers. Now we are ready to print code coverage for all tests we've run: |
| 547 | + |
| 548 | +``` |
| 549 | +$ coverage report |
| 550 | +Name Stmts Miss Cover |
| 551 | +----------------------------------------------------------- |
| 552 | +mbed_lstools\__init__.py 2 0 100% |
| 553 | +mbed_lstools\lstools_base.py 246 169 31% |
| 554 | +mbed_lstools\lstools_darwin.py 88 77 13% |
| 555 | +mbed_lstools\lstools_linux_generic.py 148 51 66% |
| 556 | +mbed_lstools\lstools_ubuntu.py 5 0 100% |
| 557 | +mbed_lstools\lstools_win7.py 112 60 46% |
| 558 | +mbed_lstools\main.py 90 63 30% |
| 559 | +----------------------------------------------------------- |
| 560 | +TOTAL 691 420 39% |
| 561 | +``` |
| 562 | + |
531 | 563 | # Configure mbed-enabled device to work with your host |
532 | 564 |
|
533 | 565 | ## Windows serial port configuration |
|
0 commit comments