我在试用版测试套件中发现了一个问题,在出现超时之前一切正常。如果测试由于超时而失败,则永远不会调用 tearDown 函数,从而使 react 堆不干净,进而导致其余测试失败。我认为 tearDown 应该在超时后调用,有人知道为什么会发生这种情况吗?
最佳答案
无论测试中发生什么,都应该调用 tearDown()
是正确的。来自 the documentation对于 tearDown()
:
This is called even if the test method raised an exception
但是,有一个问题。来自同一文档:
This method will only be called if the setUp() succeeds, regardless of the outcome of the test method.
所以听起来你可能在 setUp()
中启动 react 堆,当它超时时,这会阻止你的 tearDown()
运行 - 这个想法是无论您在 setUp()
中尝试“设置”什么,都未成功设置,因此您不想尝试将其拆除。但是,除非您提供 setUp
和 tearDown
方法的代码,以及任何相关测试的代码,否则很难做出准确的诊断。
关于python - 在扭曲试验中超时后没有调用 tearDown?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39883058/