Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 684
Rachel Avatar asked May 04 '11 19:05

Rachel


People also ask

Why Spring is used in tester?

It ensures performance and quality of the product. The Java platform supports many testing frameworks. Spring introduces the principle of dependency injection on unit testing and has first-class support for integration testing.

Is Spring framework used in testing?

Unit testing with Spring FrameworkIf you follow the standard Spring Framework architecture, the dependency injection and use of Mock Objects can make Unit testing super convenient for you. Testing individual code and modules, i.e., isolation tests, is easy to execute using Mock Objects.


1 Answers

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.

like image 198
Joseph Ottinger Avatar answered Oct 04 '22 02:10

Joseph Ottinger