Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个 MUnit 测试,并想模拟我的测试中使用的一些 bean,但我不知道如何将它们注入流中。这在 MUnit 中可能吗?
我知道您的应用程序中有一个 bean,并且您想更改它的工作方式以进行测试,这是正确的吗?
首先要说的是,MUnit 只模拟消息处理器。因此,无法模拟配置或 spring bean 等顶级元素。
不过,您可以做的是,将您的 spring bean 定义在一个与您的逻辑分开的文件中。当您运行测试时,您只需导入应用程序逻辑所在的文件,并为您的实现提供缺少的 bean。
高温高压