TDD_UT测试总结
TDD_UT测试总结
编写测试用例
访问私有方法:
#define private public
#include "xxx.h"
#undef private#define private public
#define protected public
#include "xxx.h"
#undef protected
#undef private
访问.c文件的静态方法:
#ifdef _cplusplus
extern "C" {
#include "xxx.c"
}
#endif
或
直接添加:
#include "xxx.c"
cpp文件:
/** Copyright (c) 2022 Huawei Device Co., Ltd.* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/#include <gtest/gtest.h>using namespace testing::ext;
using namespace OHOS::XXX;
using namespace OHOS::Security::AccessToken;class AVSessionControllerTest : public testing::Test {public:static void SetUpTestCase();static void TearDownTestCase();void SetUp() override;void TearDown() override;std::shared_ptr<AVSession> avsession_ = nullptr;std::shared_ptr<AVSessionController> controller_ = nullptr;static constexpr int64_t TestMicroSecond = 1000;static constexpr int SESSION_LEN = 64;
};void AVSessionControllerTest::SetUpTestCase()
{g_selfTokenId = GetSelfTokenID();AccessTokenIDEx tokenIdEx = AccessTokenKit::AllocHapToken(g_info, g_policy);SetSelfTokenID(tokenIdEx.tokenIdExStruct.tokenID);
}void AVSessionControllerTest::TearDownTestCase()
{SetSelfTokenID(g_selfTokenId);auto tokenId = AccessTokenKit::GetHapTokenID(g_info.userID, g_info.bundleName, g_info.instIndex);AccessTokenKit::DeleteToken(tokenId);
}void AVSessionControllerTest::SetUp()
{OHOS::AppExecFwk::ElementName elementName;elementName.SetBundleName("demo");elementName.SetAbilityName("demo");avsession_ = AVSessionManager::GetInstance().CreateSession("Application", AVSession::SESSION_TYPE_AUDIO,elementName);ASSERT_NE(avsession_, nullptr);auto ret = AVSessionManager::GetInstance().CreateController(avsession_->GetSessionId(), controller_);ASSERT_EQ(ret, AVSESSION_SUCCESS);ASSERT_NE(controller_, nullptr);
}void AVSessionControllerTest::TearDown()
{avsession_->Destroy();controller_->Destroy();
}class XXX1: public XXX2{public:void XXX() override;
};AVControllerCallbackImpl::~AVControllerCallbackImpl()
{}void AVControllerCallbackImpl::XXX()
{isDestory_ = true;
}/**
* @tc.name: Destroy001
* @tc.desc: XXX
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(AVSessionControllerTest, Destroy001, TestSize.Level1)
{EXPECT_EQ(controller_->Destroy(), AVSESSION_SUCCESS);EXPECT_EQ(controller_->Destroy(), ERR_CONTROLLER_NOT_EXIST);
}
gn文件:
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")module_output_path = "xxx/xxx"###############################################################################
config("module_private_config") {visibility = [ ":*" ]include_dirs = ["../../include/","../../../../../../interfaces/xxx/xxx/xxx/include/",]
}common_deps = ["//third_party/googletest:gtest_main",
]common_external_deps = [
]ohos_unittest("AVSessionManagerTest") {module_out_path = module_output_pathsources = [ "xxx_test.cpp" ]configs = [ ":module_private_config" ]deps = common_depsexternal_deps = common_external_deps
}ohos_unittest("XXXTest") {module_out_path = module_output_pathsources = [ "avsession_controller_test.cpp" ]configs = [ ":module_private_config" ]deps = common_depsexternal_deps = common_external_deps
}###############################################################################
group("unittest") {testonly = truedeps = [":XXXTest",]
}
###############################################################################
外部gn文件:
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.import("//build/ohos.gni")
import("//foundation/xxx/xxx/config.gni")config("xxx_client_config") {include_dirs = ["//xxx/include",]
}ohos_shared_library("xxx_client") {install_enable = trueipc_sources = ["//xxx/xxx.cpp",]client_sources = []sources = ipc_sources + client_sourcespublic_configs = [ ":xxx_client_config" ]public_deps = ["//foundation/multimedia/av_session/frameworks/common:avsession_common","//foundation/multimedia/av_session/utils:avsession_utils",]external_deps = []
}
编译测试用例
编译用例:
32位:
./build.sh --product-name rk3568 --build-target make_test./build.sh --product-name rk3568 --build-target xxx_test64位:
./build.sh --product-name rk3568 --ccache --target-cpu arm64 --build-target xxx_test
#单独生成group的测试用例
./build.sh --product-name rk3568 --build-target XXXTest
生成测试用例位置
/out/rk3568/tests/unittest/xxx
创建testcase\unittest\xxx\xxx位置如下:
D:\file_work\22.6.13(test)\testcase\unittest\xxx\xxx
将测试用例copy到session文件夹
烧镜像流程
编译镜像:
./build.sh --product-name rk3568 --ccache
镜像路径:
\out\rk3568\packages\phone\images\
rk3568烧录
D:\file_work\22.5.23(3568烧录流程)
复制测试工具文件到本地
/home/openharmony/test$ ls
将developertest和xdevice复制到D:\file_work\22.6.13(test)
修改配置文件
修改D:\file_work\22.6.13(test)\developertest\config下的user_config.xml文件,如下图
<test_cases><dir>D:\file_work\22.6.13(test)\testcase</dir>
</test_cases>
手动拉起av_session进程
蓝区selinux临时关闭及手动拉起av_session进程方法:
hdc_std shell setenforce 0
hdc_std shell service_control start av_session查看进程是否起来:
hdc_std shell pgrep "av_session"
运行start.bat
双击developertest下的start.bat
输入3,回车
跑测试用例
-t [TESTTYPE]: 指定测试用例类型,有UT,MST,ST,PERF,FUZZ,BENCHMARK等。(必选参数)
-tp [TESTPART]: 指定部件,可独立使用。
-tm [TESTMODULE]: 指定模块,不可独立使用,需结合-tp指定上级部件使用。
-ts [TESTSUITE]: 指定测试套,可独立使用。
-tc [TESTCASE]: 指定测试用例,不可独立使用,需结合-ts指定上级测试套使用。
-h : 帮助命令。
run -t UT -ts AvsessionManagerTest -tc CreatSession_001run -t UT -ts AvsessionManagerTestrun -t UT
查看运行结果
在developertest下的reports中查看运行结果
查看summary_report.html
测试结果
测试用例的结果会直接显示在控制台上,执行一次的测试结果根路径如下:
reports/xxxx-xx-xx-xx-xx-xx
测试用例格式化结果
result/
测试用例日志
log/plan_log_xxxx-xx-xx-xx-xx-xx.log
测试报告汇总
summary_report.html
测试报告详情
details_report.html
最新测试报告
reports/latest
TDD_UT测试总结相关推荐
- 软件测试——系统测试总结报告模板
软件测试--系统测试总结报告模板 目录 编写目的 背景 用户群 定义 测试对象 测试阶段 测试工具 参考资料 测试概要 进度回顾 测试执行 测试用例 测试环境 网络拓扑 测试结果 Bug趋势图 问题类 ...
- 性能测试总结(三)--工具选型篇
性能测试总结(三)--工具选型篇 本篇文章主要简单总结下性能测试工具的原理以及如何选型.性能测试和功能测试不同,性能测试的执行是基本功能的重复和并发,需要模拟多用户,在性能测试执行时需要监控指标参数, ...
- 20175305张天钰 《java程序设计》第四周课下测试总结
第四周课下测试总结 错题 某方法在父类的访问权限是public,则子类重写时级别可以是protected. A .true B .false 正确答案:B 解析:书P122:子类不允许降低方法的访问权 ...
- 入门级----测试的执行、环境的搭建、每日构建、测试记录和跟踪、回归测试、测试总结和报告...
测试用例的准备,都是为了执行测试准备的. 测试环境的搭建 (1)测试数据:有些测试需要使用大批量的数据,例如容量测试.压力测试等.根据产品的具体测试要求,可能需要在数据库表插入大量的数据,准备大量的文 ...
- android冒烟测试自动化,安卓自动化测试总结(五)——测试结果发送及内容展示...
安卓自动化测试总结(五)--测试结果发送及内容展示 使用jenkins自动构建并完成自动化测试后,如果想看测试结果,都需要打开jenkins构建地址,找到对应的构建及构建结果.这样做很麻烦,关心自动化 ...
- C++对象内存布局测试总结
C++对象内存布局测试总结 http://hi.baidu.com/����/blog/item/826d38ff13c32e3a5d6008e8.html 上文是半年前对虚函数.虚拟继承的理解.可能 ...
- 温升测试总结setllom解胶剂
测试流程: 一定要提前准备好所有东西,列个清单,明确使用的工具,并且提前一周拿到所有设备,进行预先测试,排查可能出现的故障. 温升探头可能存在故障:事先放在水里对所有探头进行检测: 找采购部买好胶水( ...
- 测试总结该怎么写...
最近参与了几次面试,面试者的简历中都会提及:需求或者版本测试结束后会进行版本总结,而不仅仅是提供一份测试报告. 于是特意追问了一下,总结中都包含什么内容,答复上基本都是围绕此次测试过程中发现的BUG数 ...
- 谈软件测试人员定位---三年软件测试总结
因为一直从事web产品的测试,我的观点并不一定适合所有的类型项目. 工作已将近三年了,虽然这三个年头里我都在积极的学习着与测试相关的技术:但是能沉淀的东西很少.相信测试同学都有类似的感觉. 不要为了测 ...
最新文章
- 一次愉快的 bug 修复经历
- 反思~我们是否应当克制对新技术的追求?
- 阿里云推出免费套餐 30余款云产品半年免费
- 外挂学习之路(3)--- 内存遍历工具
- JS取消浏览器文本选中的方法
- python什么时候用进程什么时候用线程_Python多线程/多进程释疑:为啥、何时、怎么用?...
- 前端常见跨域解决方案
- leetcode字节跳动探索
- MSSQL为单独数据库创建登录账户
- 【带权并查集经典例题】银河英雄传说【同POJ 1988 cube stacking】
- 数据库设计-简化字典表
- Mac 生成ico图标
- 用户体验优化事半功倍:如何绘制客户行为轨迹图
- iOS开发中屏幕旋转(二)
- 如何将notepad++设置为默认打开方式
- 计算机电缆对绞外径怎样算,计算机电缆国家标准是什么
- 为何如今在主板上找不到北桥了?简述主板芯片组发展史
- ESP8266 12F 点灯科技APP 控制两个舵机
- html 简单机器人对话页面,简单的机器人对话功能实现 js
- 软件测试-offer选择,自研or外包
热门文章
- Designing for iPhone 4's Retina Display
- SAX 方式解析 XML
- 万字技术干货 |YMatrix 高性能时序数据库引擎的技术实践
- Sea.js 使用总结(1)
- java毕业设计大学生心理健康系统Mybatis+系统+数据库+调试部署
- 奥塔在线:vsftp用户及权限管理体系初探
- 关键词下降应该怎么办?
- 解析因人工智能技术变革而产生的价值观
- 202101-话/镜:世界因语言而不同
- CentOS7 运维 - 磁盘管理与文件系统 | 超详细 | 附挂载教程及错误排查 | parted超大磁盘分区教程