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
sgm_forcesgm_force 

Generating failures in Batch Class processing for code coverage

Hi everyone,

 

I need to generate failures in the execution of a batch class in order to cover a significant amount of the batch class code.

Any idea on how I can go about this?

 

 

Thanks in advance,

 

SGM

davescardavescar

Each test method in your unit test is it's own unique test, meaning, among other things, the database is "reset" as each test method begins.  In your unit test, you should be creating the data you will be testing against. 

 

So, assuming you are doing this, it shouldn't be too difficult to create "bad" data or, at least, data designed to try to break your code.  

sgm_forcesgm_force

Will it be possible for you to give me some example....What are the different scenarios in which I can cause a batch failure?

 

Thanks.