He-Pin opened a new issue, #3218:
URL: https://github.com/apache/pekko/issues/3218
### Motivation
`ManualTime.expectNoMessageFor` 使用 `Duration.Zero` 作为超时参数调用
`expectNoMessage`,导致刚刚入队的消息可能被漏检,测试结果不可靠。
### 当前代码行为
`ManualTime.scala` 中:
```scala
// ManualTime.scala:76-79
override def expectNoMessageFor(duration: FiniteDuration): Unit = {
on.foreach(_.expectNoMessage(Duration.Zero)) // 应为 duration 而非
Duration.Zero
}
```
`expectNoMessage(Duration.Zero)` 意味着不等待任何时间就检查,如果消息刚好在此刻入队,可能被漏检。
### 预期行为
应使用 probe 的默认等待时间或传入的 `duration` 参数来检查,确保在指定时间窗口内没有消息到达。
### 代码证据
-
`actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/scaladsl/ManualTime.scala:76-79`
— `expectNoMessageFor` 实现
### 复现方式
```scala
// 在 ManualTime 测试中
val probe = testKit.createTestProbe[String]()
testKit.scheduler.scheduleOnce(1.milli, () => probe.ref ! "msg")
probe.expectNoMessageFor(100.millis) // 应该检测到消息,但可能漏检
```
### 影响范围
- 模块:`pekko-actor-testkit-typed`
- 影响所有使用 `ManualTime` 和 `expectNoMessageFor` 的测试
- 可能导致测试假阳性(应该失败但通过了)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]