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
developer srideveloper sri 

can anyone tell me test class structure for below class

can somebody help me writing Test class for below class:

 

public with sharing class classone {

 public static double getmethod1l( String param 1, 
       String param2, decimal param3){
       
        double method1Qty = 0;
        
       If ( param1.contains('32x2x33') && (param1.contains('pentium1') || 
         param1.contains('Core_')) && !param1.contains('AQ') && 
         !param1.contains('12W') && !param2.contains('LED')){
                                 
                method1Qty = param3;           
            
        }
        return method1Qty;
        
   } // end of getmethod1     

digamber.prasaddigamber.prasad

Hi,

 

Below code will help you:-

 

@isTest
private class classone_Test {

    static testmethod void testclassone() {
		Double dGetU = classone.getmethod1l('32x2x33pentium1Core_', 'test', decimal.valueOf(10));
		
	}
}

 

nathaForcenathaForce

Hi developer sri,

 

In addition to what digamberlucky replied, here are a couple of links that will help you for future test classes:

http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests

http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_error_handling.htm for VF page and controllers

 

Most important being the use of asserts, bulk testing for triggers as well as Test.StartTest()/Test.StopTest().