I've recently implemented a functional feature in an ERP system. This feature is a promotion evaluation process that
(1)Checks a sales order and loads all valid promotions.
(2)Depending on the configuration of the model of a particular promotion, it assesses the order and gives the corresponding reward if any.
Hope I explained it well!
For example if a customer has bought 7 products, (say product X) and lucky him, there's a promotion that says buy 7X get 50% discount, that customer (as you guessed) will get 50% discount...Simple isn't it
My question is I've been trying to figure out how to write a unit test for that process.
The thing is, there is only one public method to that class and it is the startProcess() method (which obviously launches the process).
I may be wrong but I think it is not possible to test this method....I mean the process can have an extremely large no. of possible inputs (sales orders) and an equally large no. of outputs (rewards), everything being subject to the no. of promotions available! How is it possible to write a unit test for that??
I hope somebody can help me...I'm going crazy here! Maybe my idea of unit test is totally wrong...I believe that unit testing in java is about testing a class (i.e. a unit in java). Testing a class means testing all its public methods. Am I right? If so, is it possible to test such a process?