You need to sign in to do that
Don't have an account?
EvertonSzekeres
Test class tasks closed
I'm trying to make my test class understand that all the tasks are closed.
The problem is it in "LIMIT 1" but if I remove "LIMIT 1" I get this:
System.QueryException: List has more than 1 row for assignment to SObject
Stack Trace: Class.Email_abertura_de_vaga_test.myUnitTest001: line 23, column 1
This is my class:
The problem is it in "LIMIT 1" but if I remove "LIMIT 1" I get this:
System.QueryException: List has more than 1 row for assignment to SObject
Stack Trace: Class.Email_abertura_de_vaga_test.myUnitTest001: line 23, column 1
This is my class:
@isTest (seeAllData=true) public class Email_abertura_de_vaga_test { static testMethod void myUnitTest001() { User u = [select id, Name from User where Name='CP7 Marketing']; Case ct = new Case(); ct.Func_abertura_chamado__c = 'EVERTON GOMES'; ct.motivo__c='Abertura de vaga'; ct.subject='test'; ct.Description='test test'; ct.resposta__c=null; ct.Nome_atendimento__c=null; ct.N_veis__c=null; ct.Meios_de_divulga_o__c=null; ct.Candidatos_agendados__c=null; ct.Candidatos_avaliados__c=null; ct.Candidatos_pr_selecionados__c=null; ct.status = 'Novo'; insert ct; Task t = [select id, whatid from Task where isClosed=true LIMIT 1]; ct.status = 'Fechado'; ct.status_do_processo__c = null; ct.id = t.whatid; ct.Func_abertura_chamado__c = 'THIAGO MARTINS'; ct.Nome_atendimento__c='Teste'; ct.N_veis__c='Recepcionista'; ct.Meios_de_divulga_o__c='TEste'; ct.Candidatos_agendados__c=12; ct.Candidatos_avaliados__c=10; ct.Candidatos_pr_selecionados__c=2; ct.In_cio__c= Date.today(); ct.resposta__c='teste'; update ct; }
Task T (single record reference) So either you havt to put limit to or you need to declare T as List<task>T
ct.id = t.whatid; this line will be changed to ct.id = t[0].whatid;
And when I try to deploy my test class, I get my respective error above here.
Because I have in my production different cases with more than one task that is not completed in the same case.
I tried change my test class with you have suggested to me.
So, trying to deploy this test class I get the error:
"Você não pode fechar um chamado com tarefas abertas. "'+t.subject+'" está aberta. Verificar com '+t.owner.name+'" = "You can't close a case with tasks still opened. "'+t.subject+'" is opened. Check with '+t.owner.name+"'
Fechado = Closed