Issue
In my recent role, I transitioned from C to Java. Our project has a standard java project structure as laid out by Apache Maven. I am able to run Junit tests from Intellij with no problems.
But I am curious about how the application logic spread across /src/main/ is made available to the test logic in /src/test.
Is Unit testing framework responsible for this? or build tool creates a temporary jar which includes test classes along with application classes as governed by their respective package structures?
Thanks for your responses!
Solution
But I am curious about how the application logic spread across /src/main/ is made available to the test logic in /src/test.
Is Unit testing framework responsible for this?
No.
or build tool creates a temporary jar which includes test classes along with application classes as governed by their respective package structures?
You could configure a build that would create a temporary jar file which includes test classes along with application classes, but that is not the normal thing. Normally the build tool (Maven in your case) will compile all of the code to .class
files and put all of those .class
files on the CLASSPATH when the tests are run. All classes that are available on the CLASSPATH will be accessible in the tests when tests are run.
Answered By - Jeff Scott Brown
Answer Checked By - Cary Denson (JavaFixing Admin)