-
Notifications
You must be signed in to change notification settings - Fork 3k
Unit testing framework #7819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit testing framework #7819
Conversation
UNITTESTS/README.md
Outdated
static uint32_t count = 0; | ||
|
||
// Test stubs | ||
osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) { return retval; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples should follow our coding style (please run astyle on this code and update the example)
{ | ||
char *n = 0; | ||
EXPECT_EQ(iface->get_mac_address(), n); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No newline in t hese files? Leave one please
UNITTESTS/README.md
Outdated
### Testing with Python script: | ||
|
||
``` | ||
./UNITTESTS/mbed_unittest.py test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this how we want to introduce this tools ? Shouldn't this be mbed unittest
rather? and this scripts to be moved into tools/
folder
@@ -0,0 +1,13 @@ | |||
#include "events/mbed_shared_queues.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add license headers to the new files, like this one
UNITTESTS/stubs/EventFlags.cpp
Outdated
@@ -0,0 +1,24 @@ | |||
#include "rtos/EventFlags.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATHandler_stub
- has suffix, but some of the stubs do not have, like this one. Is there a naming convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few example unit tests are from features/cellular/UNITTESTS without major changes to demonstrate how to convert existing unit tests to use this framework. So ATHandler_stub for example is from these existing tests which uses that naming convention. These unit tests introduced in this PR are not final in any form including naming. Their purpose is only to showcase the framework before proper unit tests are written/converted.
UNITTESTS/README.md
Outdated
### Testing with Mbed CLI | ||
|
||
``` | ||
mbed unittest test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please describe what will be the behavior of new code when executing mbed compile
. All C/CPP files inside unittest
folder will not be build or will be skipped during linking step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am now reviewing Icetea addition. So back to this mbed unittest
comment I had earlier today.
Icetea has it as mbed test -m <target> -t <toolchain> --icetea
. This should follow it ? as mbed test -m <target> -t <toolchain> --unittest
or just this unittest
Just looking for alignment (icetea / unittest/ app test) - if there can be any. Adding my comment here to this line (hijacking @deepikabhavnani question that is however related)
@OPpuolitaival Please review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the unittesting is basically target and toolchain agnostic.
It runs the one provided by the host OS.
So it is so different from what mbed test
is targeting, that it requires its own command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SeppoTakalo is right, we need separated command because:
"mbed test" - testing code which runs on embedded device and therefore need a target and toolchain
"mbed unittest" - testing code units in host computer using documented compilers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, own command
UNITTESTS/README.md
Outdated
### Testing with Mbed CLI | ||
|
||
``` | ||
mbed unittest test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SeppoTakalo is right, we need separated command because:
"mbed test" - testing code which runs on embedded device and therefore need a target and toolchain
"mbed unittest" - testing code units in host computer using documented compilers
UNITTESTS/README.md
Outdated
|
||
Traditional software testing is defined into three main levels: unit testing, integration testing and system testing. These levels are often pictured as a pyramid to indicate the amount of testing per level. | ||
``` | ||
^ Testing level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SeppoTakalo should we move this picture in testing introduction in Handbook?
UNITTESTS/README.md
Outdated
* GCC 6 or later | ||
* MinGW-W64 GCC-6.4.0 or MinGW-W64 GCC-7.3.0 (Windows) | ||
* CMake 3.0+ installed. | ||
* Python and pip installed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which python versions we support? Need to define. And maybe pip also. Something like python 2.7.x or >3.5
UNITTESTS/README.md
Outdated
* MinGW-W64 GCC-6.4.0 or MinGW-W64 GCC-7.3.0 (Windows) | ||
* CMake 3.0+ installed. | ||
* Python and pip installed. | ||
* gcovr and optionally virtualenv pip modules installed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcovr version definition?
UNITTESTS/README.md
Outdated
mbed unittest test | ||
``` | ||
|
||
##### Parameters to mbed unittest test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel good to list these here because these are coming from mbed-cli and mbed-cli works with any version of Mbed OS. Then we don't have guarantee that these are like this forever.
UNITTESTS/README.md
Outdated
mbed unittest new | ||
``` | ||
|
||
##### Parameters to mbed unittest new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't list parameters here because there is no guarantee. Just command and why it exist is good enough
Is it a bit too early to describe Also, don't remove anything from the README.md, once ready, we just submit part of it into Mbed OS handbook. |
Referencing Mbed CLI here should be ok, because it is mentioned elsewhere in the repo as well(case greentea), and it would not take long to get new mbed-cli release out (PR is ongoing). |
OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theotherjimmy Please check the location for the scripts here (in the UNITTESTS folder rather than tools/unittests or similar). If that is fine.
Not really. Both PRs can be active in parallel, and we can even merge one before another, as long as we make sure they're released together. But it looks like y'all are already moving forward with that. |
@cmonr you are right. Mbed-cli need to work for many Mbed OS version which means that it works also without unit tests in repository. PRs can be merged in any order |
@0xc0170 I accepted this |
/morph build |
Build : SUCCESSBuild number : 2923 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2543 |
UNITTESTS/README.md
Outdated
``` | ||
virtualenv pyenv | ||
pyenv\\Scripts\\activate | ||
pip install 'gcovr>=4.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good, well done! I give a quick try, everything works just fine, apart from this line.
Seems on my windows 10, pip not like the single quotes, but only works with double quotes. please confirm @lorjala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, single quotes do not work when using default command prompt, but they do with powershell.
Test : SUCCESSBuild number : 2674 |
/morph build |
Build : SUCCESSBuild number : 2942 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2559 |
Test : SUCCESSBuild number : 2691 |
Description
Unit testing framework for writing, building and running Mbed OS unit tests for developers and contributors.
MBEDOSTEST-3
Pull request type