test: improve unit test coverage to 70% and fix eventlogutils bug#692
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 unit tests across low-coverage modules to raise line coverage above 70%. 为多个低覆盖模块新增单元测试,将前端行覆盖率提升至70%以上。 Fix missing-braces bug in eventlogutils::writeLogs that caused early return. 修复eventlogutils的writeLogs缺大括号导致提前返回、日志永不写入的bug。 Log: 提升单元测试覆盖率至70% Influence: 前端行覆盖率由62.0%提升至70.3%,全部970个测试通过,零失败;顺带修复eventlogutils日志写入bug。
8ae31ee to
9324d0f
Compare
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // eventlogutils.cpp 已修复完成,无需进一步改动
// 以下为符合规范的测试代码片段示例,展示如何避免全局静态变量污染
class UT_DeviceFactorySafe : public UT_HEAD
{
public:
void SetUp() override
{
// 在每个用例中局部设置桩,避免全局状态污染
m_stub.set(ADDR(Common, getArch), []() { return "x86_64"; });
}
void TearDown() override
{
m_stub.reset();
}
private:
Stub m_stub;
};
TEST_F(UT_DeviceFactorySafe, getDeviceGenerator_x86_64)
{
DeviceGenerator *g = DeviceFactory::getDeviceGenerator();
EXPECT_NE(dynamic_cast<X86Generator *>(g), nullptr);
delete g;
} |
|
[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 |
|
/merge |
Add unit tests across low-coverage modules to raise line coverage above 70%.
为多个低覆盖模块新增单元测试,将前端行覆盖率提升至70%以上。
Fix missing-braces bug in eventlogutils::writeLogs that caused early return.
修复eventlogutils的writeLogs缺大括号导致提前返回、日志永不写入的bug。
Log: 提升单元测试覆盖率至70%
Influence: 前端行覆盖率由62.0%提升至70.3%,全部970个测试通过,零失败;顺带修复eventlogutils日志写入bug。