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
SolidLucasSolidLucas 

test class help!

Somenone could help me to do a class test for this method?

private void loadBase(){
		listBase = [
			SELECT	Id,
					Name,
					QtdePontos__c,
	    			QtdeUnidadesConsumidoras__c,
	    			QtdeSaloesFestas__c,
	    			QtdeZeladorias__c,
	    			InvestimentoUG__c,
					InvestimentoCliente__c,
					InicioObra__c,
					InicioConsumo__c,	    			
	    			Comentarios__c,
	    			IndexController__c,
	    			AnaliseInvestimento__c,
	    			(SELECT	Id,
							Name,
							Quantidade__c,
					        AiInstalacao__c,			                                                    
					        ValorOrcado__c,
					        Servico__c,
					        IndexController__c	    			
					  FROM InstalacoesServicos__r),
					(Select Id, 
							Name, 
							Atividade__c, 
							Instalacao__c, 
							Responsabilidade__c, 
							Valor__c 
					  From Itens_de_Obras__r),
					(Select Id, 
							Name, 
							Quantidade__c, 
							Kit__c, 
							Kit__r.Valor__c,
							Kit__r.Descricao__c, 
							Instalacao__c 
					  From KitsInstalacoes__r),
					(Select Id, 
							Name, 
							Comodato__c, 
							Quantidade__c, 
							ValorOrcado__c, 
							Instalacao__c, 
							EquipamentoMaterial__c,
							EquipamentoMaterial__r.Tipo__c,
							EquipamentoMaterial__r.Name 
					  From EquipamentosMateriaisInstalacoes__r),
					  
					(Select Id, 
							Name, 
							ConsumoPrevistoMensal__c, 
							FatorIncremento__c, 
							FilialAbastecedora__c, 
							IcmsOrigem__c, 
							IcmsDestino__c, 
							PrecoVenda__c, 
							Produto__c, 
							ExRefinaria__c 
						From InstalacoesProdutos__r) 
			FROM AiInstalacao__c 
			WHERE AnaliseInvestimento__c = :analiseInvestimento.Id
		];		
		
		mapService = new Map<Id, list<InstalacaoServico__c>>();
		mapObras = new Map<Id, list<AiItemObra__c>>();
		mapKits = new Map<Id, list<AiKitInstalacao__c>>();
		mapMateriais = new Map<Id, list<AiEquipamentoMaterialInstalacao__c>>();
		mapConsumo = new Map<Id, list<AiConsumoInstalacao__c>>();
		Set<Id> setBaseId = new Set<Id>();
		for (AiInstalacao__c mBase: listBase){ 
			mapService.put(mBase.Id,  mBase.InstalacoesServicos__r);
			mapObras.put(mBase.Id,  mBase.Itens_de_Obras__r);
			mapKits.put(mBase.Id,  mBase.KitsInstalacoes__r);
			mapMateriais.put(mBase.Id,  mBase.EquipamentosMateriaisInstalacoes__r);
			mapConsumo.put(mBase.Id,  mBase.InstalacoesProdutos__r);			
			//colecionando lista de Id das Instacões do projeto
			setBaseId.Add(mBase.Id);
		}
		
		loadConsumo(setBaseId);
		
		selectFirstBase();
	}
 
/**
	  * Constructor 
	 **/
	public AnaliseInvestimentoConsulta_ctl(ApexPages.StandardController con){ 
		analiseInvestimento = (AnaliseInvestimento__c) con.getRecord();
		loadBase();
		
		subTabIndexActive = '0'; 
	}
SonamSonam (Salesforce Developers) 
Helping with the test class would be easier if you would give a brief of what you trying to do in the code and share, if you have written any test code yet..If not, I would encourage you to do the same and post the lines where you are facing difficulty in writing the test method.
Some places you can read to get you started:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_test.htm
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
SolidLucasSolidLucas
@isTest
private class tst_AnaliseInvestimentoConsulta {

    static testMethod void myUnitTest() {
    	
 
    }
   
      	@TestVisible private static void loadBase(){
      		
	  	  	AnaliseInvestimento__c listBase = new AnaliseInvestimento__c(  
	  	  	
	    	InvestimentoUG__c = 1000,
			InvestimentoCliente__c = 2000,
			InicioObra__c = Date.valueOf( Datetime.now().addDays(-5)),
			InicioConsumo__c = Date.valueOf( Datetime.now().addDays(-7)),
			Oportunidade__c = '006Q000000Cz4jm',
			PrazoContrato__c = Date.valueOf( Datetime.now().addDays(-9)),
			MultaContratual__c = 5000,
			DiasPrazoPagamento__c = 150
	      	);
	      	
	      	Opportunity opp = new Opportunity(
	      	AnaliseInvestimento__c = '006Q000000Cz4jm'	
	      	);
	      	
			
				
	     	insert listBase;
	     	
    }
    
   		@TestVisible private static void loadConsumo (){
   			 ExRefinaria__c listConsumo = new ExRefinaria__c(
   			 //Produto__c,
   			 Validade__c = Date.valueOf( Datetime.now().addDays(-9)),
   			 Valor__c = 10.5
   			);
   			
   			
   			insert listConsumo;
   	}
   	
   	public void callPrivateMethods(){
   		loadConsumo();
		loadBase();
   	}
i've did this so far. i want to test my soql.
SonamSonam (Salesforce Developers) 
After looking at your code, I understand that the main object from where you are fetching data is 
AiInstalacao__c
so in the test class you should be creating the AiInstalacao__c record with the  related records with the fields such that they fall under the SOQL SELECT filter and then compare the value of returned SOQL record with the one you entered - it should be the same.