问题标签 [gomega]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
11 浏览

gomega - gomege Expect 不去测试失败

我正在运行一个 go 测试,如下所示:

其中有 gomege Expect 声明。问题是 Expect 确实会导致测试失败,即使它应该失败,我不知道为什么。谢谢

0 投票
1 回答
71 浏览

go - 如何使用 ginkgo/gomega 测试无限循环/递归?

我有一个 golang 函数,它递归地遍历 json 字符串,并用它们引用的 json 文档替换自定义引用。我只是注意到我忘了处理循环引用,循环引用的出现会导致无限递归。在我解决这个问题之前,我想为这个案例编写一个测试(使用 ginkgo/gomega),这样我可以验证我的解决方案是否有效,如果我打破它并再次遇到这个问题,我会注意到。

但是我该怎么做if this function call does not return within <timeout>, abort it and fail the test呢?

Gomega'sEventually有一个超时,但如果它已经在运行,它不会中止该函数,因此在这种情况下它将永远阻塞。

我找到了如何使用和通道检查超时的示例select,但据我了解,不可能从外部终止 goroutine - 所以我的函数将继续在后台运行,占用资源?

检查无限递归的最佳方法是什么?