embedded-framework/test/test_develop.md
2023-11-21 07:32:42 -08:00

59 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 1. 测试用例开发规范
  便于对测试用例进行管理,指定测试用例开发规范。
## 1.1. 命名规则
* 测试用例命名:
1. 测试用例类型含单元测试UNIT和集成测试INTEGRATION
2. 用例所属模块:大小驼峰;
3. 测试用例属性EXAMPLE/AUTO/STRESS
4. 测试用例小名;
示例:
```
TEST(SharedDataTest, UNIT_SharedData_DEME_Demo7)
{
// TODO:
}
```
* 测试源码文件命名:
1. 每个测试可执行文件都有一个标准mian函数文件名统一为mainTest.cpp;
```
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <thread>
#include <unistd.h>
int main(int argc, char *argv[])
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); // 此处执行所有的测试用例;
}
```
2. 针对源码文件对应的测试代码文件名为源码文件名_Test.cpp;
```
例如cjson.c 对应的测试源码文件为cjson_Test.cpp
```
3. 适配层源码文件的TEST文件命名区分Simulator版本和常规版本Simulator版本在ubuntu模拟仿真环境测试执行代码会调用芯片SDK接口常规版本必须运行在开发板
```
├── CMakeLists.txt
├── mainTest.cpp
├── src
│   └── BoardMain_Test.cpp // 常规测试代码,可运行在开发板系统;
└── src_mock
└── BoardMain_Simulator_Test.cpp // 运行过程会调用芯片依赖的API,需要对这些API进行mock处理实现Linux x86平台的仿真测试
```
4.
## 1.2. 目录结构
&emsp;&emsp;所有测试代码位于<test>目录下,<test>下的目录结构保持和<SDK>一致表示对应sdk代码模块的测试代码
如果是芯片平台的test目录需要区分板载测试代码和x86 Linux系统的测试代码如下
```
└── hal
├── CMakeLists.txt
├── mainTest.cpp
├── src // 芯片平台的测试代码
└── src_mock // Linux x86测试代码 需要对板载接口打桩进行测试;
```