Basically, the value of static field will remain across test cases. So either you don't use static field, or remember to reset its value to default value in setUp(). Be careful, or you will get the most tricky bug promisingly.
Be careful of static field when unit testing!
最新推荐文章于 2025-12-30 14:55:22 发布
本文探讨了在软件测试中使用静态字段可能遇到的问题。建议要么避免使用静态字段,要么确保在每个测试用例之前通过setUp()方法将其重置为默认值。否则可能会引入难以追踪的错误。
1436

被折叠的 条评论
为什么被折叠?



