test(coop): add cooperation core module coverage tests - #770
Conversation
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Add tests for Settings, ConfigManager, CommonUitls, filesystem, CooperationUtil, phone helpers and discover controller safe paths. Add crash signal handler in main.cpp to flush gcov on SIGSEGV. 新增cooperation核心模块测试,覆盖配置管理、通用工具、文件系统、 协作工具、手机模块和发现控制器的安全路径。main.cpp添加崩溃信号 处理器以确保段错误时刷新gcov覆盖率数据。 Log: 添加cooperation模块覆盖率测试 Influence: 仅新增测试文件和main.cpp信号处理,不影响现有功能逻辑。
b37bb1c to
b333e68
Compare
deepin pr auto review★ 总体评分:75分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 --- a/tests/coop/CMakeLists.txt
+++ b/tests/coop/CMakeLists.txt
@@ -99,5 +99,5 @@ endif()
if(VNCCLIENT_LIBRARY)
target_link_libraries(coop_tests PRIVATE ${VNCCLIENT_LIBRARY})
endif()
-target_link_options(coop_tests PRIVATE -fprofile-arcs -ftest-coverage -Wl,--allow-multiple-definition)
+# TODO: 排查并修复符号重复定义根因后移除 --allow-multiple-definition
+target_link_options(coop_tests PRIVATE -fprofile-arcs -ftest-coverage)
add_test(NAME coop_tests COMMAND coop_tests)
--- a/tests/coop/commonutils_test.cpp
+++ b/tests/coop/commonutils_test.cpp
@@ -20,6 +20,8 @@ TEST(CommonUitlsTest, GenerateRandomPasswordProducesVariedOutput)
{
QString a = CommonUitls::generateRandomPassword();
QString b = CommonUitls::generateRandomPassword();
+ // 验证两次调用产生不同结果(极小概率相同,可放宽为多次采样)
+ EXPECT_NE(a, b);
EXPECT_EQ(a.length(), 6);
EXPECT_EQ(b.length(), 6);
}
--- a/tests/coop/configmanager_test.cpp
+++ b/tests/coop/configmanager_test.cpp
@@ -19,7 +19,6 @@ TEST(CoopConfigManagerTest, AppSettingReturnsValidSettings)
{
Settings *s = ConfigManager::instance()->appSetting();
ASSERT_NE(s, nullptr);
- EXPECT_NE(s, nullptr); // 移除冗余断言,ASSERT_NE已足够
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Add tests for Settings, ConfigManager, CommonUitls, filesystem, CooperationUtil, phone helpers and discover controller safe paths. Add crash signal handler in main.cpp to flush gcov on SIGSEGV.
新增cooperation核心模块测试,覆盖配置管理、通用工具、文件系统、
协作工具、手机模块和发现控制器的安全路径。main.cpp添加崩溃信号
处理器以确保段错误时刷新gcov覆盖率数据。
Log: 添加cooperation模块覆盖率测试
Influence: 仅新增测试文件和main.cpp信号处理,不影响现有功能逻辑。