简体   繁体   中英

What are the benefits of Spring Framework in Terms of Testing Application?

We have heard a lot about Benefits of Spring like it offers loose coupling, dependency injection, inversion of control etc but from testing point of view, I have couple of question.

  • What are the advantages of Spring Framework in terms of testing an application?
  • Why Application developed using Spring as considered my testable as opposed to other Web Application?

Please provide some useful examples as then it would be much more easier to understand explanation. I am new to Spring as such and want to understand precise benefits offered by Spring Framework from Application Developer point of view?

An application geared towards dependency injection is typically more testable because resources are easily replaced with test-oriented resources. Consider a service object that uses a data access object; in production, you'd inject a DAO that talked to a backend data store. But for each test you could create a DAO that returned specific, known data; this allows you to focus on the object being tested.

Spring is one of many dependency injection frameworks for Java, albeit the most popular; any DI framework is going to give you this kind of benefit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM