3 title: Test Framework Functions
5 https://git.automotivelinux.org/apps/app-afb-test/plain/docs/Reference/2_TestFrameworkFunctions.md?h=master
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 -->
10 # Test Framework functions
12 * **_AFT.addEventToMonitor(eventName, callback)**
14 Add a binding event in the test framework to be able to assert its reception
15 . You'll need to add as much as events you expect to receive. You could also
16 specify a callback to test deeper that the event is as you want to. The
17 callback will happens after the assertion that it has been received so you
18 can work on data that the event eventually carry.
20 * **_AFT.setJunitFile(filePath)**
22 Set the *JUnit* file path. When *JUnit* is set as the output type for the
25 * **_AFT.setBeforeEach(function)**
27 Set the **_AFT.beforeEach()** function which is used to run the *function*
30 * **_AFT.setAfterEach(function)**
32 Set the **_AFT.afterEach()** function which is used to run the *function*
35 * **_AFT.setBeforeAll(function)**
37 Set the **_AFT.beforeAll()** function which is used to run the *function*
38 before all tests. If the given function is successful it has to return 0
39 else it will return an error.
41 * **_AFT.setAfterAll(function)**
43 Set the **_AFT.afterAll()** function which is used to run the *function*
44 after all tests. If the given function is successful it has to return 0
45 else it will return an error.
47 * **_AFT.describe(testName, testFunction, setUp, tearDown)**
49 Give a context to a custom test. *testFunction* will be given the name
50 provided by *testName* and will be tested.
52 *setUp* and *tearDown* are functions that can be added to your context,
53 it works just like **_AFT.beforeEach()** and **_AFT.afterEach()**,
54 *setUp* will be ran before your *testFunction* and **_AFT.beforeEach()**
55 (if set) functions, *tearDown* will be ran after your *testFunction* and
56 **_AFT.afterEach()** (if set) functions.
58 * **_AFT.setBefore(testName, beforeTestFunction)**
60 Set a function to be ran at the beginning of the given *testName* function.
63 _AFT.testVerbStatusSuccess('testPingSuccess','hello', 'ping', {})
64 _AFT.setBefore("testPingSuccess",function() print("~~~~~ Begin testPingSuccess ~~~~~") end)
65 _AFT.setAfter("testPingSuccess",function() print("~~~~~ End testPingSuccess ~~~~~") end)
68 * **_AFT.setBefore(testName, beforeTestFunction)**
70 Set a function to be ran at the end of the given *testName* function.