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
Santosh Reddy9989Santosh Reddy9989 

Force.com Security Source Code Scanner treating getter method as test method in test class

Hi,

Force.com Security Source Code Scanner treating getter method as test method in test class and giving Quality Issues (Query: Test Methods With No Assert).
 
sample code :

@isTest
public class StripePlanTests {

    public static String testData_getPlan {
        get {
            return '{'+
            '  "interval": "year",'+
            '  "name": "Cirrus Insight Annual Subscription",'+
            '  "created": 1354825845,'+
            '  "amount": 0,'+
            '  "currency": "usd",'+
            '  "id": "CI_ANNUALLY",'+
            '  "object": "plan",'+
            '  "livemode": false,'+
            '  "interval_count": 1,'+
            '  "trial_period_days": null,'+
            '  "statement_description": null'+
            '}';
        }
    }
    public static Map<String, String> payload {
        get{
            Map<String, String> payload1 = new Map<String, String>();
            payload1.put('interval','year');
            payload1.put('name','Cirrus Insight Annual Subscription');
            payload1.put('amount','0');
            payload1.put('currency','usd');
            payload1.put('id','CI_ANNUALLY');
            payload1.put('interval_count','1');
            payload1.put('trial_period_days','null');
            return payload1;
        }
    }
}

User-added image
Best Answer chosen by Santosh Reddy9989
Amit Chaudhary 8Amit Chaudhary 8
You can ignor the same method you can update the code like below
@isTest
public class StripePlanTests {

    public static String testData_getPlan = '{'+
											'  "interval": "year",'+
											'  "name": "Cirrus Insight Annual Subscription",'+
											'  "created": 1354825845,'+
											'  "amount": 0,'+
											'  "currency": "usd",'+
											'  "id": "CI_ANNUALLY",'+
											'  "object": "plan",'+
											'  "livemode": false,'+
											'  "interval_count": 1,'+
											'  "trial_period_days": null,'+
											'  "statement_description": null'+
											'}';
    
    public static Map<String, String> payload = new Map<String, String>{ 'interval'=>'year' , 'name'=>'Cirrus Insight Annual Subscription' ,'amount' => '0' ,'currency'=>'usd' ,'id'=>'CI_ANNUALLY' , 'interval_count'=> '1' , 'trial_period_days' =>'null' };
	
}

Let us know if this will help you
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
You can ignor the same method you can update the code like below
@isTest
public class StripePlanTests {

    public static String testData_getPlan = '{'+
											'  "interval": "year",'+
											'  "name": "Cirrus Insight Annual Subscription",'+
											'  "created": 1354825845,'+
											'  "amount": 0,'+
											'  "currency": "usd",'+
											'  "id": "CI_ANNUALLY",'+
											'  "object": "plan",'+
											'  "livemode": false,'+
											'  "interval_count": 1,'+
											'  "trial_period_days": null,'+
											'  "statement_description": null'+
											'}';
    
    public static Map<String, String> payload = new Map<String, String>{ 'interval'=>'year' , 'name'=>'Cirrus Insight Annual Subscription' ,'amount' => '0' ,'currency'=>'usd' ,'id'=>'CI_ANNUALLY' , 'interval_count'=> '1' , 'trial_period_days' =>'null' };
	
}

Let us know if this will help you
 
This was selected as the best answer
Santosh Reddy9989Santosh Reddy9989
Thanks  amit