You need to sign in to do that
Don't have an account?
mhitt
errors in test class
Hello,
I am getting these errors in my test class, can I please have some help fixing the issues?
Class
Test class
Errors:
line 24: Variable does not exist: ConvToCstId
line 26: Method does not exist or incorrect signature: void getConvToCst() from the type convToCst
I tried to copy the code from this but for some reason it is producing errors on this test class: https://developer.salesforce.com/forums/ForumsMain?id=9062I000000ISkfQAG
Thanks,
I am getting these errors in my test class, can I please have some help fixing the issues?
Class
public class convToCst { public DateTime dateField{ get; set; } public string dateFormat { get; set; } public string dateTimeZone { get; set; } public string output { get {return dateField.format(this.dateFormat,this.dateTimeZone);} } }
Test class
@isTest private class TestConvToCst { @TestSetup static void setupTestData() { Account acc = new Account( Name = 'Test Account'); insert acc; Contact con = new Contact( FirstName = 'Test', LastName = 'Contact', AccountId = acc.Id ); insert con; eVolve_Service_Request__c ESR = new eVolve_Service_Request__c(Signing_Party_Type__c = 'Seller', Signing_Date_Requested_Start__c = system.today()+5, Status__c = 'New', Contact_Name__c = con.Id ); insert ESR; } @isTest static void validateconvToCst() { ConvToCst cst = new ConvToCst(); cst.ConvToCstId = [Select Id from eVolve_Service_Request__c limit 1].Id; List<ESR_Signing_Party__c> esp = cst.getConvToCst(); system.assertEquals('Test Party', esp[0].Name__c); } }
Errors:
line 24: Variable does not exist: ConvToCstId
line 26: Method does not exist or incorrect signature: void getConvToCst() from the type convToCst
I tried to copy the code from this but for some reason it is producing errors on this test class: https://developer.salesforce.com/forums/ForumsMain?id=9062I000000ISkfQAG
Thanks,
About this custom class convToCst:
The class does not have a property named ConvToCstId to receive the Id.
The class also doesn't have a method named getConvToCst().
In the class, you should have a method, with a returning type. Something like:
Do you have more details on what this method is supposed to do or return?
So what the class does is it converts the system GMT timezone to CST to display the scheduled date/time correctly on a VF email template. It was converting correctly on the template so I didn't know it needed to return the Id (I'm new to the coding world). I also forgot I needed a test class entirely and tried to deploy this past weekend - but I digress. My goal is to get at least 75% code coverage so I can complete deployment.
To retreive the Id, all I need to do is add this to the end of my class, then I can use it on the Test class? And this should resolve the line 24 error?
And I'm sorry, but which class would this belong in?
Could you also please walk me through this? I'm don't really understand the question. As mentioned this (and the linked class) are my first time using Apex.
Thank you for the help