You need to sign in to do that
Don't have an account?
Mick Man
test class
I am new with salesforce, I have an Apex class and I would like to create a test for this class but I have no idea, can someone help me please
public class NouveauProduitExtensions { public NouveauProduitExtensions(ApexPages.StandardController controller) { } public PageReference cancel() { return Page.Nouveau_produit; } public JointMatProd__c Jointure {get; set;} public Produit__c prod { get; set; } public NouveauProduitExtensions() { prod = new Produit__c(); Jointure = new JointMatProd__c(); } public PageReference showAddMatierePage() { return Page.Produit_Add_Matiere; } public PageReference Save() { insert prod; insert Jointure; PageReference acctPage = new ApexPages.StandardController(prod).view(); acctPage.setRedirect(true); return acctPage; } public List<cMatiere> matiereList {get; set;} public List<JointMatProd__c> JointList {get; set;} public List<MatierePremiere__c> selectedMatieres{get;set;} public Integer value {get;set;} public List<cMatiere> getMatieres() { if(matiereList == null) { matiereList = new List<cMatiere>(); for(MatierePremiere__c c : [select Id, Name, Unite__c from MatierePremiere__c]) { matiereList.add(new cMatiere(c)); } } return matiereList; } public PageReference processSelected() { selectedMatieres = new List<MatierePremiere__c>(); JointList = new List<JointMatProd__c>(); for (cMatiere cMat : getMatieres()) { if(cMat.selected == true) { selectedMatieres.add(cMat.mat); } } value = selectedMatieres.size(); System.debug('printing listcontc'+selectedMatieres.size()); for (MatierePremiere__c mat : selectedMatieres) { JointList.add(new jointMatProd__c(Produit__c = prod.id, MatierePremiere__c = mat.id, Quantite__c=0)); } return page.Nouveau_produit; } public class cMatiere { public MatierePremiere__c mat {get; set;} public Boolean selected {get; set;} public cMatiere(MatierePremiere__c c) { mat = c; selected = false; } } }
You can have a look at this article, it details out the exact process of writing a test class.
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods