I currently have an interesting situation occurring with my code, and after hacking away at what turned out to be a dead end for the last two weeks, I'm here asking those smarter than I to educate me on where I went wrong, and how I can perform my intended task correctly.
We have a set of classes that perform various tasks but do so on one object that they pass around. Actions are performed to this object in each class before finally being processed and then sent back to the display layer for front end processing. This is a brief description of how the process works.
A collection of users is submitted via front end form The collection of users is processed into an object with various parameters set within. Multiple classes with various methods that process the object that was just created are executed one at a time. In each class, the object has various methods that perform tasks on certain actions, such as formulas, validation, etc. the object is then sent to the front end for display of the processed object.
I'm attempting to build JUnit tests to help automate testing for this group of classes. This is how i have it configured
testConfiguration - instead of a form submission, I create a collection of users in various configurations based upon what we need to do for testing
testMain - This is the "root" class. It takes a configuration from the testConfiguration class needed for the current test run, creates it into an object with various parameters based upon the users passed, and then passed into the various classes for further processing
testClassesProcess - various classes that take the processed object from testMain, perform various actions on it (mainly mathematical type methods) and then return.
Ran into a few really. The first is that you can't pass parameters to functions in JUnit tests, as it'll come up with initializeErrors. Also the @Autowired annotation in the classes being tested error out with
NullPointerException, turns out that if enter the classes being tested from the JUnit suite, and they can't seem to resolve the variable that would be used with no issue when executed via the application normally.
WE currently use Java 1.7 with Hibernate, Spring, and JUnit to help give a visual of our stack.
So I'm wondering if after describing my situation if I'm trying to make JUnit put a round peg in square hole, if I'm just using JUnit wrong, or if there's a better solution that I could use to test this setup.
EDIT: My apologies if this seems vague. It's a workplace issue so I try not to give away anything proprietary, and to make it so others could relate.