+ Start a Discussion
viswadaviswada 

system.assertEquals error in production

Hi all,

 

     I am  moving  one  apex class from sandbox to production.   it is uploaded succesfully  in sandbox,  when i am  validating   that class in production ,  i  am getting  "system.assertEquals   error", becuase of two test classes in procution, ,I don't have t two test classes in my sandbox to put comments  that lines, what can i do  to resolve this prob, I am using changesets  for deploying , any one can help me 

SamuelDeRyckeSamuelDeRycke

Could we see some of your code  ? It is pretty hard to answer anything based on the information you've given so far. Did you also run the tests in your sandbox organisation ? They could have already been failing there, this to my knowledge only becomes a blocking issue on a production organisation.

 

 

bob_buzzardbob_buzzard

Do your tests fail in production without your deployment, or is it your tests that are causing the failure?

viswadaviswada

No  iam not getting  any error in  my test class  ,  it was uploaded   succesfully, 

viswadaviswada

actully my calss and test calss is  

public class weeksreportctrl1
{
public list<countofweek> weekcounts{set;get;}
public list<weekname> weeknames{set;get;}
public class weekname{
Public String Wname{set;get;}
}
public class weekcount{
public Integer w1{get;set;}
public weekcount(){
w1=0;
}
}
public class countofweek{
Public String Name{set;get;}
public list<weekcount> weekobjcount{set;get;}
public countofweek(){
weekobjcount=new list<weekcount>();
}
}

public list<Lead> Dateenterdlist=new list<Lead>();
public list<Lead> Basicslist=new list<Lead>();
public list<Lead> Appinlist=new list<Lead>();
public list<Lead> Integererviewlist=new list<Lead>();
public list<opportunity> Docslist=new list<opportunity>();
public list<lead> leadslist=new list<lead>();
public map<string,id> recordt=new map<string,id>();
public weeksreportctrl1()
{
weekcounts=new list<countofweek>();
weeknames=new list<weekname>();
if(weekcounts.size()>0)
weekcounts.clear();
Date dtoday;
Date d24;
Date dstart;
Date dend;

if(system.today().month()>=2&&system.today().month()<=7){
dtoday=Date.newInstance(system.today().year(),1,30);
d24=Date.newInstance(system.today().year(),7,29);
dstart=dtoday;
dend=d24;
}
else if((system.today().month()>=8&&system.today().month()<=12)){
dtoday=Date.newInstance(system.today().year(),7,30);
d24=Date.newInstance(system.today().year()+1,1,27);
dstart=dtoday;
dend=d24;
}
else if(system.today().month()==1){
dtoday=Date.newInstance(system.today().year()-1,7,30);
d24=Date.newInstance(system.today().year(),1,27);
dstart=dtoday;
dend=d24;
}
for(recordtype r:[select id,Name from recordtype where SobjectType='lead'])
if(r!=null)
recordt.put(r.name,r.id);

for(recordtype r:[select id,Name from recordtype where SobjectType='opportunity'])
if(r!=null)
recordt.put(r.name,r.id);
//system.debug(r.name);

/*for(opportunity opp:[select Cancelled__c from opportunity where Cancelled__c>=:dtoday and Cancelled__c<=:d24 and Cancelled__c!=:null and recordtypeid=:recordt.get('ILP Signup Type') limit 50000])
{
Dateenterdlist.add(opp);
}
for(opportunity opp:[select Basics__c from opportunity where Basics__c>=:dtoday and Basics__c<=:d24 and Basics__c!=:null and recordtypeid=:recordt.get('ILP Signup Type') limit 50000])
{
Basicslist.add(opp);
}
for(opportunity opp:[select App_in__c from opportunity where App_in__c>=:dtoday and App_in__c<=:d24 and App_in__c!=:null and recordtypeid=:recordt.get('ILP Signup Type') limit 50000])
{
Appinlist.add(opp);
}
for(opportunity opp:[select Interview__c from opportunity where Interview__c>=:dtoday and Interview__c<=:d24 and Interview__c!=null and recordtypeid=:recordt.get('ILP Signup Type') limit 50000])
{
Integererviewlist.add(opp);
}*/
for(Lead opp:[select Cancelled__c from Lead where Cancelled__c>=:dtoday and Cancelled__c<=:d24 and Cancelled__c!=:null and recordtypeid=:recordt.get('ILP Volunteer Lead') and type__c=:'ILP Volunteer Teacher' limit 50000])
{
Dateenterdlist.add(opp);
}
for(Lead opp:[select Basics__c from Lead where Basics__c>=:dtoday and Basics__c<=:d24 and Basics__c!=:null and recordtypeid=:recordt.get('ILP Volunteer Lead') and type__c=:'ILP Volunteer Teacher' limit 50000])
{
Basicslist.add(opp);
}
for(Lead opp:[select App_in__c from Lead where App_in__c>=:dtoday and App_in__c<=:d24 and App_in__c!=:null and recordtypeid=:recordt.get('ILP Volunteer Lead') and type__c=:'ILP Volunteer Teacher' limit 50000])
{
Appinlist.add(opp);
}
for(Lead opp:[select Interview__c from Lead where Interview__c>=:dtoday and Interview__c<=:d24 and Interview__c!=null and recordtypeid=:recordt.get('ILP Volunteer Lead') and type__c=:'ILP Volunteer Teacher' limit 50000])
{
Integererviewlist.add(opp);
}
for(opportunity opp:[select Docs_in__c from opportunity where Docs_in__c>=:dtoday and Docs_in__c<=:d24 and Docs_in__c!=:null and recordtypeid=:recordt.get('ILP Signup Type') limit 50000])
{
Docslist.add(opp);
}
for(lead l:[select Createddate from lead where createddate>=:dtoday and createddate<=:d24 and recordtypeid=:recordt.get('ILP Volunteer Lead') limit 50000])
{
leadslist.add(l);
}

Date dhstart=dstart;
while(dhstart<=dend){
Date dt1;

dt1=dhstart;

dhstart=dt1.adddays(7);

string result =string.valueof(dt1);
weekname wn=new weekname();
wn.Wname=result.substring(5,7)+'/'+result.substring(8,10);
weeknames.add(wn);
}
if(leadslist.size()>0||leadslist.size()==0){
countofweek c=new countofweek();
c.Name='ILP Volunteer Leads';
Date dl=dstart;
while(dl<=dend){
weekcount wc=new weekcount();
Date dt1;
dt1=dl;
dl=dt1.adddays(7);
for(lead opp:leadslist){
if(opp.Createddate!=null){
if(opp.Createddate>=dt1 && opp.Createddate<dl){
wc.w1=wc.w1+1;
}
}
}
c.weekobjcount.add(wc);
}
weekcounts.add(c);
}
if(Basicslist.size()>0||Basicslist.size()==0){
countofweek c=new countofweek();
c.Name='Basics';
Date Db=dstart;

while(Db<=dend){

weekcount wc=new weekcount();
Date dt1;
dt1=Db;
db=dt1.adddays(7);
for(Lead opp:Basicslist){
if(opp.Basics__c!=null){
if(opp.Basics__c>=dt1 &&opp.Basics__c<db){
wc.w1=wc.w1+1;
}
}
}
c.weekobjcount.add(wc);
}
weekcounts.add(c);
}
if(Integererviewlist.size()>0||Integererviewlist.size()==0){
countofweek c=new countofweek();
c.Name='Interview';
Date Di=dstart;
while(Di<=dend){
weekcount wc=new weekcount();
Date dt1;
dt1=Di;
Di=dt1.adddays(7);
for(Lead opp:Integererviewlist){
if(opp.Interview__c!=null){
if(opp.Interview__c>=dt1 &&opp.Interview__c<Di){
wc.w1=wc.w1+1;
}
}
}
c.weekobjcount.add(wc);
}
weekcounts.add(c);
}
if(Appinlist.size()>0||Appinlist.size()==0){
countofweek c=new countofweek();
c.Name='App In';

date dapp=dstart;
while(dapp<=dend){
weekcount wc=new weekcount();
Date dt1;
dt1=Dapp;
dapp=dt1.adddays(7);
for(Lead opp:Appinlist){
if(opp.App_in__c!=null){
if(opp.App_in__c>=dt1 &&opp.App_in__c<dapp){
wc.w1=wc.w1+1;
}
}
}
c.weekobjcount.add(wc);
}
weekcounts.add(c);
}

if(Docslist.size()>0||Docslist.size()==0){
countofweek c=new countofweek();
c.Name='Docs-in';
Date Dd2=dstart;
while(Dd2<=dend){
weekcount wc=new weekcount();
Date dt1;
dt1=dd2;
Dd2=dt1.adddays(7);
for(opportunity opp:Docslist){
if(opp.Docs_in__c!=null){
if(opp.Docs_in__c>=dt1 && opp.Docs_in__c<Dd2){
wc.w1=wc.w1+1;
}
}
}
c.weekobjcount.add(wc);
}
weekcounts.add(c);
}
if(Dateenterdlist.size()>0||Dateenterdlist.size()==0){
countofweek c=new countofweek();
c.Name='Cancelled';
date dde=dstart;

while(dde<=dend){
weekcount wc=new weekcount();
Date dt1;
dt1=dde;
dde=dt1.adddays(7);

for(Lead opp:Dateenterdlist){
if(opp.Cancelled__c!=null){
if(opp.Cancelled__c>=dt1 &&opp.Cancelled__c<dde){
wc.w1=wc.w1+1;

}
}

}
c.weekobjcount.add(wc);
}
weekcounts.add(c);
}

}
public list<countofweek> getwlist()
{
return weekcounts;
}
public list<weekname> getweeknames1()
{
if(weeknames.size()>0)
return weeknames;
else
return null;
}
public Pagereference excel()
{
pagereference pr=new pagereference('/apex/WeekReport_Excel');

return pr;
}
public Pagereference epdf()
{
pagereference pr=new pagereference('/apex/WeekReport_Pdf');

return pr;
}

public static testmethod void weekreporttest(){
opportunity opp=new opportunity(Name='abctest',closedate=system.today(),StageName='Prospecting',Interview__c=system.now(),Basics__c=system.now(),Cancelled__c=system.now());
insert opp;
lead l=new lead(Lastname='abc',Company='bcd');
insert l;
weeksreportctrl1 w=new weeksreportctrl1();
w.getwlist();
w.getweeknames1();
w.excel();
w.epdf();
}
}

 

 and i  got 83%   without errors

bob_buzzardbob_buzzard

I can't see any assert statements in there.

viswadaviswada




UnfollowTests.verifyBooleanNotEqualTo()Class12651Failure Message: "System.AssertException: Assertion Failed: Expected: 0, Actual: 4", Failure Stack Trace: "Class.UnfollowTests.verifyBooleanNotEqualTo: line 1265, column 1"
UnfollowTests.verifyDateTimeEqualsToday()Class6321Failure Message: "System.AssertException: Assertion Failed: Expected: 4, Actual: 0", Failure Stack Trace: "Class.UnfollowTests.verifyDateTimeEqualsToday: line 632, column 1"
UnfollowTests.verifyDaysDelayDupeRecordID()Class13651Failure Message: "System.AssertException: Assertion Failed: Expected: 2, Actual: 0", Failure Stack Trace: "Class.UnfollowTests.verifyDaysDelayDupeRecordID: line 1365, column 1"








Bob  actully , i in my apex class there  is no problem , when i am validating  i am getting reeors like System.assertion exception, assertion failed.  The  eroors lik

 

 
bob_buzzardbob_buzzard

If you run those tests in production without trying to deploy your code, do you still see the failures.

viswadaviswada

Yes ,  if i run those test classes  i am getting  test failures,actually those test class is  no available in in my sandbox,   i can i fix this problem

bob_buzzardbob_buzzard

You'll need to refresh a sandbox to contain those test classes and fix the tests I'm afraid.

viswadaviswada

yes Bob, i am afraid, Some other members  Moved those test classes   directly  with validating the code,  There  are around 57 "system assertion exceptions: assertion failed " are there.  shall i  download thoset test classes ,modify them , that is the only thing  infornt me  , are  you right  bob