Home > Software engineering >  Unit testing practical scenarios
Unit testing practical scenarios

Time:11-30

Hopefully this question is allowed as it is subjective. But I'm struggling to discover a real world example as to why you need to do unit testing in Angular? All the example videos I see are basic in the nature of what they're testing for. Most are testing to see if a button is on the page or whatever. But that seems to be a pretty pointless test. Could someone please give me an example?

CodePudding user response:

I helped work on an app that would display results within relative date ranges (today, last 7 days, this school year, etc.). Writing unit tests helped ensure that the proper date range was being selected in each case. I could "feed" the tests a "today" in June or in November and ensure that the calculated start and end dates were correct.

Granted, this is still a fairly simple example, where manual testing often suffices. However, this can give us confidence that the functions are still working as expected if we were to change the datepicker we're using, for instance, without having to manually re-test everything.

  • Related