You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[greentea-client support in your module](#greentea-client-support-in-your-module)
10
-
*[Terms](#terms)
4
+
*[Concepts](#concepts)
11
5
*[Test suite](#test-suite)
12
6
*[Test case](#test-case)
13
7
*[key-value protocol](#key-value-protocol)
14
-
*[Where can I use it?](#where-can-i-use-it)
15
-
*[Test suite model](#test-suite-model)
16
-
*[utest support template](#utest-support-template)
17
-
*[No utest support template](#no-utest-support-template)
8
+
*[Test example](#test-examplel)
18
9
19
10
# greentea-client
20
11
21
-
**Tip:** If you are unsure about the terms used in this document, please see the [Terms](#Terms) section.
22
-
23
-
```greentea-client``` is a C++ client library for [the Greentea test tool](https://github.com/ARMmbed/greentea) when used in an [mbed](www.mbed.com) project.
24
-
This package implements the slave side of the simple key-value protocol used for communication between the device under test (DUT) and the host. ```Greentea``` on the host side implements the protocol's master behavior. ```greentea-client``` is released through the [yotta registry](https://yotta.mbed.com/#/module/greentea-client/0.1.8).
12
+
`greentea-client` is a client library for [the Greentea test tool](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-greentea) when used in an [Mbed OS](https://os.mbed.com/) project.
25
13
14
+
This package implements the client side of the key-value protocol used for communication between the device under test (DUT) and the host. The `Greentea` tool implements the protocol's host behavior. We use [utest](https://github.com/ARMmbed/mbed-os/blob/master/features/frameworks/utest/README.md) as our test harness.
26
15
27
16
```
28
-
DUT <--- serial port connection ---> host
29
-
(slave) . (master)
17
+
DUT <--- serial port connection ---> host
18
+
(client) . (host)
30
19
.
31
20
[greentea-client] . [conn_process] [htrun]
32
21
===== . ================ =========
@@ -47,100 +36,24 @@ This package implements the slave side of the simple key-value protocol used fo
47
36
.
48
37
```
49
38
50
-
```greentea-client``` is a [yotta module](http://yottadocs.mbed.com/reference/module.html). You can easily include it in your yotta project as ```dependency```/```testDependency```.
51
-
52
-
## mbed-drivers dependencies
53
-
54
-
This package was introduced as a future replacement for the [mbed-drivers/test_env.h](https://github.com/ARMmbed/mbed-drivers/blob/master/mbed-drivers/test_env.h) test framework. ```mbed-drivers/test_env.h``` is no longer considered the correct way to write tests for mbed modules.
55
-
56
-
Examples of test cases ported from the old ```mbed-drivers/test_env``` to the ```greentea-client``` model can be found here:
```Greentea``` is a test automation tool written in Python and designed to automate test execution for [mbed](www.mbed.com) projects encapsulated as [yotta](http://yottadocs.mbed.com) modules. Its key features include: integration with yotta module, test automation for yotta module's tests and reporting.
If you wish to use ```greentea-client``` please make sure you are using latest ```Greentea``` tools from [PyPI](https://pypi.python.org/pypi/mbed-greentea) (you will need Python 2.7):
80
-
```
81
-
$ pip install mbed-greentea --upgrade
82
-
```
83
-
84
-
*Note*: If you previously used ```mbed-drivers/test_env.h``` features to write your test cases please downgrade ```Greentea``` to a version lower than ```v0.2.0``` to stay compatible:
85
-
```
86
-
$ pip install "mbed-greentea<0.2.0" --upgrade
87
-
```
88
-
89
-
*Note*: [Greentea v0.1.x](https://github.com/ARMmbed/greentea/tree/master_v0_1_x) is still developed on a ```master_v0_1_x``` branch. We will only apply critical patches to version 0.1.x, no feature development is planned.
90
-
91
-
### utest support
92
-
93
-
```utest``` is our preferred test harness which allows you to execute a series of (asynchronous) C++ test cases. ```greentea-client``` includes as test dependency ```utest``` yotta module. See the ```greentea-client```[module.json](https://github.com/ARMmbed/greentea-client/blob/master/module.json)```testDependency``` section:
94
-
```json
95
-
{
96
-
"testDependencies": {
97
-
"utest": "^1.10.0"
98
-
}
99
-
}
100
-
```
101
-
102
-
### greentea-client support in your module
103
-
104
-
Currently ```greentea-client``` is in on version ```1.0.x```. Please use a ```^1.0.0``` dependency version in your ```module.json``` file.
105
-
106
-
Example of ```module.json``` file with ```greentea-client``` as a test dependency:
107
-
```json
108
-
{
109
-
"testDependencies": {
110
-
"greentea-client": "^1.0.0",
111
-
"utest" : "^1.10.0",
112
-
"unity" : "^2.1.0"
113
-
}
114
-
}
115
-
```
116
-
117
-
## Terms
39
+
## Concepts
118
40
119
41
### Test suite
120
-
A test suite is a binary containing test cases we execute on hardware. The test suite has a beginning and an end (like your ```main()``` function would. The test suite may pass, fail or be in an error state (for example if test suite times out or there was a serial port connection problem).
121
42
122
-
### Test case
43
+
A test suite is a binary containing test cases we execute on hardware. The test suite has a beginning and an end (like the `main()` function would. The test suite may pass, fail or be in an error state (for example, if the test suite times out or there was a serial port connection problem).
123
44
124
-
Preferably you will use ```utest``` to define test cases . test case has the beginning and the end. During test case execution you will use ``ùnity``` assert macros, schedule MINAR callbacks, check for timeouts in your code. Your test cases may pass, fail or be in an error state which means something went wrong and we were unable to determine exactly what that was (you may have to check the logs).
45
+
### Test case
125
46
126
-
### key-value protocol
47
+
A test case is contained within a test suite. You can have multiple test cases within a test suite. `unity` assert macros are used to run the checks during the test case. Your test cases may pass, fail or be in an error state.
127
48
128
-
The key-value protocol (also called ```KiVi```) is a simple protocol introduced to the ```Greentea``` test tools. It is used to send simple text messages (events) between the DUT and the host. Each message consists of a _key_ and corresponding _value_ pair.
129
-
A ```KiVi``` message is defined as a string encapsulated between double curly braces. The key and value are separated by a semicolon (```;```).
130
-
For example: the ```{{timeout;120}}}``` string is a simple key-value message where the key "_timeout_" is associated with the value "_120_". Both ```greentea-client``` and ```Greentea``` understand this format and can detect key-value messages in a data stream. Both _key_ and _value_ are ASCII strings.
131
-
This protocol is a master-slave protocol. The host has the role of _master_ and the DUT is the _slave_.
49
+
### Key-value protocol
132
50
133
-
```greentea-client``` implements the key-value protocol tokenizer and parser.
51
+
The key-value protocol is a protocol specific to the `Greentea` test tool. It is used to send messages (events) between the DUT and the host. Each message consists of a _key_ and _value_ pair. A message is surrounded by double curly braces. The key and value are separated by a semicolon (`;`).
134
52
135
-
## Where can I use it?
136
-
It is possible to write test cases that use ```greentea-client``` and at the same time support ```mbed``` features such as [MINAR scheduler](https://github.com/ARMmbed/minar). It is also possible to mix ```greentea-client``` with other test tools we use at ```mbed``` such as [utest](https://github.com/ARMmbed/utest) and [unity](https://github.com/ARMmbed/unity).
53
+
For example, the `{{timeout;120}}}` string is a key-value message where the key `timeout` has the value `120`. Both `greentea-client` and `Greentea` understand this format and can detect key-value messages in a data stream.
137
54
138
-
You can also find references to ```greentea-client``` in many ```mbed``` packages. For example:
139
-
*[mbed-drivers](https://github.com/ARMmbed/mbed-drivers) - check its [module.json](https://github.com/ARMmbed/mbed-drivers/blob/master/module.json)
140
-
*[core-util](https://github.com/ARMmbed/core-util) - check its [module.json](https://github.com/ARMmbed/core-util/blob/master/module.json)
0 commit comments