You need to sign in to do that
Don't have an account?
CharlieLang
testMethods
I am trying to create a package and getting the following error
"No testMethods found in the selected Apex code for the package "
this is all that is in the apex code.
public with sharing class CaseExtension { public Case mycase {get; set;} public User localUser {get; set;} public CaseExtension(ApexPages.StandardController stdController) { this.mycase = (Case)stdController.getRecord(); localUser = [SELECT Id, Phone, Email, FirstName, LastName, CompanyName from User where Id =: System.UserInfo.getUserId() LIMIT 1]; this.mycase.OwnerId = localUser.Id; } }
Can someone help me with this as i'm not too sure how to resolve the problem?
Thanks!!!
Hi, Charlie
Try This below code, assuming that you are using Case as Standard Object.
static testMethod void testCase1(){
Case caseObj = new Case();
caseObj.Status = 'New';
caseObj.Type = 'Other';
caseObj.Origin = 'Web';
insert caseObj;
ApexPages.StandardController caseObj1 = new ApexPages.StandardController (caseObj);
Test.startTest();
CaseExtension controller = new CaseExtension(caseObj1);
Test.stopTest();
}
All Answers
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
still dont understand it....
do i have to create a new apex class and write what looks like a long and tedious test script just to use the tiny apex class i created...
well, force.com test class is easyer to write compare to other frameworks.
if you have 10000 line of code, some of those are from others
, then you will know having test classes, methods is not a bad idea.
Hi, Charlie
Try This below code, assuming that you are using Case as Standard Object.
static testMethod void testCase1(){
Case caseObj = new Case();
caseObj.Status = 'New';
caseObj.Type = 'Other';
caseObj.Origin = 'Web';
insert caseObj;
ApexPages.StandardController caseObj1 = new ApexPages.StandardController (caseObj);
Test.startTest();
CaseExtension controller = new CaseExtension(caseObj1);
Test.stopTest();
}
Thanks hitz, that worked a dream and in turn helped to deliver a project quicker.
THANK YOU