java - java - 使用 IgniteFuture 进行单元测试
问题描述
在我的代码中,我有以下内容:
// for the test:
// executor is an ExecutorService that will run in the current thread
// compute is an IgniteCompute (can be mocked)
String other = "blah";
IgniteFuture<String> future = compute.callAsync(callable).chainAsync(i -> myCreate(i, other), executor);
该方法myCreate
是类中的私有方法,我想确保对其进行单元测试。我尝试模拟,IgniteCompute
但结果callAsync
都chainAsync
被模拟,导致我的方法没有被调用。关于如何让真正的myCreate
方法在运行上述行的测试中运行的任何想法?
解决方案
您可以在嵌入式内存模式下启动 Ignite 进行测试。要启动节点,请使用Ignition.start(...)方法。
Ignite 节点非常轻量级,不需要太多资源即可启动。我认为,它比模拟 IgniteCompute 更容易、更透明。
推荐阅读
- ruby-on-rails - 从 excel 重新创建设计用户表
- tsql - 在 SQL Server 2016 中使用 String_Split() 拆分字符串
- javascript - 反应循环组件时引导程序 4 模态不可见
- python - binascii 真正存储在哪里?
- java - 线程同步中的 While vs If
- c# - IEnumerable
和。Linq 方法的行为在哪里? - xamarin.forms - 如何从 URL 共享链接 Xamarin 表单打开应用程序中的特定页面
- jekyll - 跳过上一篇文章时如何忽略 Jekyll 中的偏移
- ios - 在 iOS 中使用 Xcode 上传更新的应用版本
- go - 在 Go 模板中保持对 map 的无序迭代