This is my first question on Stack Overflow, so please forgive me for any poor practices in my question-asking (though I do appreciate feedback to make me better at it.)
I'm currently working on a personal project: a 2D strategy game with minimal graphics. Now that I've completed a very barebones application, I decided to start implementing unit tests (I'm using JUnit) and I quickly realized how painful that will be given my current design.
Consider a few classes from my current design: Ship, ShipWeapon, ShipProvider, and ShipWeaponProvider. A Ship contains a list of ShipWeapons that it can fire at other ships. A ShipWeapon is an object defining certain weapon characteristics (i.e. damage, accuracy, etc.) ShipProvider and ShipWeaponProvider objects are used to load Ship/Weapon definitions from a file so they can be instantiated later (i.e. shipProvider.getShip("dummyShip") returns a new Ship of type "dummyShip" as defined in the definition file.)
When I started attempting to write JUnit tests, I quickly realized what a world of hurt I've gotten myself into. A Ship depends on a ShipWeapon; to test a Ship, you need a ShipWeapon, ShipProvider, and even a WeaponProvider. To even test a ShipWeapon's fire method, you need two Ships: a source (the Ship doing the firing) and a target to shoot at. Research into this problem suggested that I have a tight coupling problem; what I could not find, however, is how I might loosely couple this particular set of classes. How might I go about doing this?