I'm very new to JUnit and this may seem somewhat obvious, but I can't seem to find a straight answer on this. I have a class that for want of a better phrase is a "Cargo" class, in that it exists solely to hold variables of different type for use with other objects(Specifically, this class is used to contain the parameters for styling and formatting table cells).
It consists mostly of getters and setters, and while I know some would say it may not be worth my time testing this class, I'm using it for practice before moving onto more complex classes.
The class itself contains a no parameter constructor as well as a constructor that requires all the instance variables of the object be passed in. When creating tests, should I use (or would it be considered best practice to use) the rich constructor in the setUp() method, or should the no args constructor be called, then do a test of the getters and setters?
If nothing is done to that member in the setter/getter then it's rather pointless but I suppose you could see it as an exercise.
You can make tests for both. If you have 5 members I would make 6 tests: 5 tests that use the no-arg constructor and each of them use a single setter and getter. The other test would have the args constructor and perform assertions on every getter.
There is a discussion about how many assertions should be in a single test and while generally I try to minimize them, I believe a single test with 5 assertions on every getter here is appropriate since you're starting from a situation which says "insert all these values" in one statement.
Some people would argue that this should be split up in 10 tests: 5 with a no-arg ctor + get/setter and 5 with a arg ctor with a single getter every time because that allows you to separate your tests to make it clear which getter you're testing.
There are no strict guidelines for this so you should decide for yourself.