samples: enhance integration sample and document it
Document the integration test sample. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
2b62f1ab02
commit
a6eee02c00
|
@ -29,9 +29,9 @@ CMakeLists.txt
|
|||
:language: CMake
|
||||
:linenos:
|
||||
|
||||
sample.yaml
|
||||
testcase.yaml
|
||||
|
||||
.. literalinclude:: ../../../samples/testing/integration/sample.yaml
|
||||
.. literalinclude:: ../../../samples/testing/integration/testcase.yaml
|
||||
:language: yaml
|
||||
:linenos:
|
||||
|
||||
|
@ -52,6 +52,37 @@ src/main.c
|
|||
:local:
|
||||
:backlinks: top
|
||||
|
||||
|
||||
|
||||
A test case project may consist of multiple sub-tests or smaller tests that
|
||||
either can be testing functionality or APIs. Functions implementing a test
|
||||
should follow the the guidelines below:
|
||||
|
||||
* Test cases function names should be prefix with **test_**
|
||||
* Test cases should be documented using doxygen
|
||||
* Test function names should be unique within the section or component being
|
||||
tested
|
||||
|
||||
|
||||
An example can be seen below::
|
||||
|
||||
/**
|
||||
* @brief Test Asserts
|
||||
*
|
||||
* This test verifies the zassert_true macro.
|
||||
*/
|
||||
static void test_assert(void)
|
||||
{
|
||||
zassert_true(1, "1 was false");
|
||||
}
|
||||
|
||||
|
||||
The above test is then enabled as part of the testsuite using::
|
||||
|
||||
ztest_unit_test(test_assert)
|
||||
|
||||
|
||||
|
||||
Quick start - Unit testing
|
||||
**************************
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
sample:
|
||||
description: TBD
|
||||
name: TBD
|
||||
tests:
|
||||
test:
|
||||
tags: my_tags
|
|
@ -6,7 +6,13 @@
|
|||
|
||||
#include <ztest.h>
|
||||
|
||||
static void assert_tests(void)
|
||||
/**
|
||||
* @brief Test Asserts
|
||||
*
|
||||
* This test verifies various assert macros provided by ztest.
|
||||
*
|
||||
*/
|
||||
static void test_assert(void)
|
||||
{
|
||||
zassert_true(1, "1 was false");
|
||||
zassert_false(0, "0 was true");
|
||||
|
@ -19,7 +25,7 @@ static void assert_tests(void)
|
|||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(framework_tests,
|
||||
ztest_unit_test(assert_tests)
|
||||
ztest_unit_test(test_assert)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(framework_tests);
|
||||
|
|
3
samples/testing/integration/testcase.yaml
Normal file
3
samples/testing/integration/testcase.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
tests:
|
||||
section.subsection:
|
||||
tags: my_tags
|
Loading…
Reference in a new issue