function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chaitanya HotaChaitanya Hota 

Could any body help me in learning how to writw test classes

User-added image

So how to write test class for conditional statement & Exceptions in order to achieve test coverage
Hi Chaitanya, i ll help you out from this problem.

I am not able the read this image. tell me what problem you are facing
Provide inputs where your condition fails

In your case you have give if(PackinAnswer.contains(newPack)), so give an input with value which contains newPack and another for not containing the Newpack. Both positive flow and negative flow,

Sameway for try catch statement also give a scenario where the delete statement in try fails and it passes through catch statements for negative flow.

This approach should give you maximum coverage.

All the best.

Please select this as best answer, if this helped you.
It seems like your test method isnt providing any anwersToDelete. Please provide the complete method and your current test method so we can help you out.