【发布时间】:2021-08-17 06:32:04
【问题描述】:
我对 Mockito 和 Java 软件测试完全陌生。 这是伪代码:
class serviceX()
{
void seedCounter(Apple apple)
{
Seed seeds = apple.getSeeds(where seed colour is red)
(if seeds is not null) print("found red seeds")
else print("found nothing")
}
}
getSeeds 是 Apple 类的一个类方法。现在我想测试seedCounter。我想测试一个场景,我假设(类似于 mockito.when(我发送一个带有红色种子的苹果)。thenReturn(notNull))我发送一个带有红色种子的苹果。我如何从中创建一个模拟场景?我想测试我是否将“找到的红色种子”作为输出。
【问题讨论】:
-
为什么没有显示
Apple和Seed的代码?
标签: java spring testing junit mockito