Any disadvantages to using spring to separate tests and data?
I've been struggling coming up with a good solution to separate my testing data from unit tests (hard coded values). Until it dawned on me that I could create beans with spring and use those beans to hold my data.
Are there any draw backs to coding my unit tests this way? Albeit they run a bit slower seeing as how spring has to configure all the beans and what not.
Asked by: Marcus229 | Posted: 28-01-2022
Answer 1
Fine practice - one of the prime motivators for dependency injection in my view (easier to unit test)
It will be slower because of the need to bring up the Spring application context, so you might reserve this technique for "integration tests".
Answered by: Rubie815 | Posted: 01-03-2022Answer 2
For unit tests you can always wire in your beans by hand, as in create and inject them yourself, then leave the Spring wiring for integration tests and production/development.
Answered by: Eric340 | Posted: 01-03-2022Similar questions
java - Are there any disadvantages of using a separate thread pool instead of common pool?
Are there any disadvantages of using custom thread pool instead of common thread pool?
Situation: Suppose i have one java application which is running on tomcat server (which having default 200 worker thread), if i create custom thread pool with 300 worker thread then this affect my application?
java - Are there any disadvantages to SEAM?
As a java web applications developer I have used this last year JSF (SUN) for a framework to my web applications. I have to say I quite liked using it, it makes the developing easier.
Recently, I have read a lot of good things about JBoss Seam, but I still haven't encountered a person that has used it. From what I have read it seems that SEAM is the next step of JSF.
My question is therefore, for you that ...
java - Web Services vs EJB vs RMI, advantages and disadvantages?
My web server would be overloaded quickly if all the work were done there. I'm going to stand up a second server behind it, to process data.
What's the advantage of EJB over RMI, or vice versa?
What about web services (SOAP, REST)?
jvm - What are the advantages and disadvantages of using Nailgun vs netcat to provide fast CLI to a Java application?
The ways to reduce startup time of Java and Scala applications have been already discussed here and here. One of the solutions suggested there was to use client-server approach with either
java - Swing to SWT conversion: which disadvantages?
We are considering to port our Swing applications to SWT/JFace to get a more native look and feel, more UI rendering speed and less bugs.
Is there anybody who already has done such a port and wants to share some information, especially disadvantages we should expect? Thanks in advance.
PS: Maybe this rather should be a wiki, because it makes no sense to accept one as the ultimate answer.
java - How to use jasper reports in my project? What are the Advantages and Disadvantages of jasper reports?
How do I implement and use jasper reports in my JSP/Servlet project? What is the advantage/disadvantages of using jasper reports?
what are the disadvantages of the JAVA inorder to work with .NET platform?
java - What are the disadvantages of Apache Wicket?
java - Advantages and disadvantages of using log4j
java - What's the advantages and disadvantages of PowerVR?
My game engine recently added PowerVR (PVR) support, after some search on Google and Wikipedia, I only know the definition of PVR, but I don't know what is it use for, what are its advantages and disadvantages. I'm developing game for Android, what should I use, PNG or PVR?
c# - What are the disadvantages to hashmaps?
Closed. This question needs to be more focused. It ...
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)