2933f740e96af06f44025b43e55e127b9353312f
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.4_AGL_Test_Framework / 2_The_test_widget / The_test_widget.md
1 ---
2 edit_link: ''
3 title: The test widget
4 origin_url: >-
5   https://git.automotivelinux.org/apps/app-afb-test/plain/docs/2_The_test_widget.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-afb-test-developer-guides-api-services-book.yml -->
9
10 # How to build the test widget using app-templates/cmake-apps-module
11
12 ## Defining CMake targets
13
14 Now that the test tree has been created, in each directory you have to create
15 a `CMakeLists.txt` file to hold the CMake's target definition. For each target
16 you need to specify a **LABELS** depending on the purpose of the files for each
17 directory. There are more explanations about using the *cmake-apps-module* (the
18 former *app-templates* submodule) in the [documentation website](../../../devguides/reference/cmakeafbtemplates/dev_guide/advanced-usage.html).
19
20 Here is a cheat sheet to map the **LABELS** target for each classic test tree
21 directory:
22
23 * `etc` uses the label **TEST-CONFIG**
24 * `fixtures` uses the label **TEST-DATA**
25 * `tests` uses the label **TEST-DATA**
26
27 i.e for the `etc` folder:
28
29 ```cmake
30 PROJECT_TARGET_ADD(afb-test-config)
31
32     file(GLOB CONF_FILES "*.json")
33
34     add_input_files("${CONF_FILES}")
35
36     SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
37         LABELS "TEST-CONFIG"
38         OUTPUT_NAME ${TARGET_NAME}
39     )
40 ```
41
42 > **CAUTION**: make sure that you have CMakeLists files that include your
43 > subdirectories target (cf: previous chapter `Write the tests`).
44
45 ## Build the test widget
46
47 By default, the test widget is not built, you have to specify that you want to
48 build it or use a special target.
49
50 ### Building at the same time than classic widget
51
52 Specify the option `BUILD_TEST_WGT=TRUE` when you configure your build.
53
54 ie:
55
56 ```bash
57 cd build
58 cmake -DBUILD_TEST_WGT=TRUE ..
59 make
60 make widget
61 ```
62
63 ### Building separately only the test widget
64
65 Just use the target `test_widget` after a classic build.
66
67 ie:
68
69 ```bash
70 cd build
71 cmake ..
72 make
73 make test_widget
74 ```