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
Aryan05Aryan05 

How to write Test Class

Hi everyone,
I need help to write a test class for my code, actually i'm new to this if anyone know please help me. Below is my code
public class TestController {
public Map<String, String> prodCounts{get; set;}
public List<String> prods{get; set;}

public String poNo;
public String getpoNo(){return poNo; }
public void setpoNo(String po) {
    poNo = po;
   TestController();
}
 
    public void TestController() {
              
        prodCounts=new Map<String, String>();
        prods=new List<String>();
        for(AggregateResult ag:[select Product2__c prod, count(Id) cnt from test_transaction__c where Po_num__c=:poNo group by Product2__c]){
            prodCounts.put(String.ValueOf(ag.get('prod')),String.ValueOf(ag.get('cnt')));
            prods.add(String.ValueOf(ag.get('prod')));         
        }
        
    }        
}