[Best Practice] 避免单元测试中的全局状态竞争问题 #851
Unanswered
Tsukikage7
asked this question in
Q&A
Replies: 1 comment
-
|
Great insights |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
背景
在 #848 PR review 过程中,发现了一个潜在的测试稳定性问题,值得在项目中推广避免。
问题描述
当测试修改全局变量时,如果使用
go test -parallel或测试框架并行执行,可能导致 flakytest(不稳定测试)。
问题代码示例:
Beta Was this translation helpful? Give feedback.
All reactions