java - 尝试找到 Maven 的 InvoiceStorage 依赖项

标签 java maven junit

我正在遵循一个具有外部类 InvoiceStorage 的教程,我认为,我对此非常菜鸟,但 java 无法解析该 InvoiceStorage 符号,所以我认为我需要一个教程中未显示的依赖项

教程链接: https://semaphoreci.com/community/tutorials/stubbing-and-mocking-with-mockito-2-and-junit


package com.mokitoTutorial.app;

import com.clusterra.email.sender.EmailSender;


public class LateInvoiceNotifier {
    private final EmailSender emailSender;
    private final InvoiceStorage invoiceStorage;

    public LateInvoiceNotifier(final EmailSender emailSender, final InvoiceStorage invoiceStorage){
        this.emailSender = emailSender;
        this.invoiceStorage = invoiceStorage;
    }

    public void notifyIfLate(Customer customer)
    {
        if(invoiceStorage.hasOutstandingInvoice(customer)){
            emailSender.sendEmail(customer);
        }
    }
}

最佳答案

在这篇文章中,作者只是提供了一个如何使用mockito的示例。您可以从上面的文章中看到以下内容。

In a real system, the InvoiceStorage class is actually a web service that connects with an external legacy CRM system which is slow. A unit test could never make use of such as web service.

作者指的是一个名为InvoiceStorage的类,它是例如。没有依赖性。您可以按照这篇文章创建自己的类来测试。

关于java - 尝试找到 Maven 的 InvoiceStorage 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58205987/

相关文章:

java - 在 javaee-api maven-project 中放置静态文件的位置

java - ExecutorService.execute() 静默退出 run() 方法

java - 列出 Eclipse 中的所有 Junit 测试用例

java - GWT map 编辑器 + validator

java - 如何对方法的立即退出进行单元测试

java - java中的batchGetItem API错误

java - 如何阻止我的小程序刷新我的 GWT 页面?

java - 带有 Spring-Boot-Starter-Parent 的多模块 Maven 项目结构

java - boolean 类型序列化和反序列化单元测试失败

java - 将键盘事件从 java 发送到任何应用程序(屏幕键盘)