+ Start a Discussion
neerureddyneerureddy 

TestMethod

Hi ,

 

I have a customcontroller, which calls BatchApex Class. Now, I need to write the testmethod.  Here, My question is whether I have to write the testmethod for controller or Batch Apex. Because I have 2 more methods in controller,which needs testmethod too. Appreciate help. Thanks in advance.

bob_buzzardbob_buzzard

You should write testmethods for both - that way you'd be able to deploy the batch or controller in isolation.  That said, I often find testing the controller allows you to exercise the rest of the code.

 

Testing batch apex has its own wrinkles - make sure to read the apex developer's guide for the test restrictions.

 

Good luck. 

neerureddyneerureddy
I wrote the testmethod for both of the  controller and Batch Apex in a single class. I got 86% code coverage for controller and 96% for BatchApex. But if I see the code coverage Total% ,In, Summary section it is showing 34%. which one I should have to consider? Is it 34% or I have to consider it separately which was dispalyed under code coverage section.
bob_buzzardbob_buzzard

The total code coverage will include any other classes/triggers etc that are present in your org.

 

If the classes you are deploying have > 75% code coverage, you should be good to go. 

neerureddyneerureddy

Thanks bob,

 

Yeah it included other classes and so many triggers. Ok... I am good to go as you said..