Git Product home page Git Product logo

Comments (1)

semi-cloud avatar semi-cloud commented on August 24, 2024 2

싱글턴 객체가 테스트하기 어려운 이유?

  1. 테스트는 일관성을 위해 매번 객체의 값이 초기화 되어야 한다. 하지만, 싱글톤 객체는 오직 하나만 존재하고 공유되기 때문에 테스트가 온전하게 수행되지 못할 수 있다.

  2. private 생성자를 막아놓으니 테스트에서 싱글턴 객체를 생성하려면 리플렉션을 활용해야 한다.

  3. Mock과 같은 가짜 객체는 주로 상속을 통해 이루어지기 때문에, 타입을 정의된 인터페이스를 구현해 만든 싱글턴이 아니라면 가짜(mock) 구현으로도 대체할 수 없어진다.

from effective-java-study.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.