3

This is a newbie question.

Let us assume that I have the following test class

@isTest
class xyz
{
  @isTest static void method1() {...code..}
  @isTest static void method2() {...code..}
  @isTest static void method3() {...code..}
}

Questions

a) Is it possible to execute only a specific methods from the above test class ?.

I always execute a test for the whole test class.

Can someone clarify whether it is possible for me to execute only a specific test method ?

b) How are the governor limits' calculation done when the whole class' methods are executed ?

For example we know that SOQL Query limit is 100 per transaction.

Does this 100 SOQL query limit is applied against all the methods (method1,method2 & method3)..or every test method has its own governor limits ?

In the above example what is the SOQL query limit for the whole test class ?

Is it still 100 to be shared across 3 methods or 300 (3 x 100 ..100 for each method) ?

Hope I am clear.

  • I really strongly recommend against testing the whole class at once. That will make valuable assertions much more challenging to write, make it more difficult to check edge cases, and make it more difficult to modify the tests if the functionality changes. – Adrian Larson Jan 20 '15 at 15:43
2

a). No, when you execute a test class, it runs every method in the test class.

b). Governor limits are reset for each test method. In addition, some governor limits are reset in between the Test.startTest() and Test.stopTest() functions used commonly in test methods.

Here's a good guide to getting started with test methods: An Introduction to Apex Code Test Methods

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.