The following are the benefits of Apex unit tests:
Ensuring that your Apex classes and triggers work as expected.
Having a suite of regression tests that can be rerun every time classes and triggers are updated to ensure that future updates you make to your app don’t break existing functionality.
Meeting the code coverage requirements for deploying Apex to production or distributing Apex to customers via packages.
High-quality apps delivered to the production org, which makes production users more productive.
High-quality apps delivered to package subscribers, which increase your customers trust.
Use the @isTest annotation to define classes and methods that only contain code used for testing your application. The @isTest annotation can take multiple modifiers within parentheses and separated by blanks.