vendredi 3 juillet 2020

How to efficiently write unit test for complex business logic in Laravel

I'm writing a room booking engine. There're 3 layers in play for the calculation : Rate Plan, Promotion, BookingQuery ( info of the request customers send in ).

When customers send in a booking query, containing info like booking date, check in date, check out date, number of people .. etc etc, this request will be passed through multiple layers of logic calculating from the Rate Plans and Promotions to give out a result ( whether or not room is available, how much is the price .. etc etc ).

I did write unit test for small calculation parts in my logic. However, I need to write an integration test, or a suite of integration test, containing hundreds of test cases of input data and expected output data. There are a lot of relationship within my entities, like $room->ratePlans, $ratePlan->promotions .. etc etc. Writing a single test case is exhausting enough, let alone hundreds.

What is the most efficient way to do this ?

Aucun commentaire:

Enregistrer un commentaire