+ Start a Discussion
rupesh ranjanrupesh ranjan 

After Uploading Package i got an error

After Uploading Package i got an error
"No test methods found in the Apex code included in the package. At least 75% test coverage is required."
My Apex Class
@isTest
public class CryptoTest {
        public CryptoTest (ApexPages.StandardController acon) { }
    String MySessionID = UserInfo.getSessionID();
    String conId = ApexPages.currentPage().getParameters().get('Id');
    String EmailCon=[Select email from Contact where Id=:conId ].email;
    String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();
    public String getFoo() {
    string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
    if(String.IsBlank(EmailCon)){ EmailCon='';}
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
     
    String b64Data = EncodingUtil.base64Encode(encryptedData);
    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
        return testurl;
    }
}
------------------------------------------------
Visual force page

<apex:page standardController="Contact" extensions="CryptoTest" > <apex:iframe src="https://www.demomail.net/demomailsfdc/sendvideo/demomailfromcontact.aspx?{!foo}&IsEnc=1" scrolling="true" id="theIframe"/> </apex:page>


 
Tarun_KhandelwalTarun_Khandelwal
Hi Rupesh,

Test class is something different from Apex class. It is not just adding @isTest annotation to any test class. 
Test class method should be static and contains testMethod keyword. For more detail, refer following link -

https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

Let me know in case of any query.
 
rupesh ranjanrupesh ranjan
OK this is my test class but its an error
@isTest(seeAllData = false)
public class CryptoTestTest{
    
    //Unit Test Method
    static testMethod void unitTest01() {
        
        Account account = new Account();
        account.Name = 'Acc1';
        insert account;
        
        Contact contact = new Contact();
       contact.FirstName = 'con1';
       contact.LastName  = 'test';
       contact.AccountID = 'account.Id';
       contact.Email = 'abc@gmail.com';
       
        insert contact;
        
        //Start test method
        test.startTest();
            ApexPages.StandardController sc = new ApexPages.StandardController(contact);//Instance of your object
            CryptoTest  ct = new CryptoTest (sc);
            PageReference pageRef = Page.SendVideoContact; // Your page name
            pageRef.getParameters().put('Id', String.valueOf(contact.Id));
            Test.setCurrentPage(pageRef);
            ct.getFoo();
        //Stop test method
        test.stopTest();
    }
}
rupesh ranjanrupesh ranjan
System.DmlException: Insert failed. First exception on row 0; first error: 
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
caused by: System.QueryException: List has no rows for assignment to SObject
rupesh ranjanrupesh ranjan
Now after RUN TEST i got error System.StringException: Invalid id: account.Id
Tarun_KhandelwalTarun_Khandelwal
You have given Id as String, which is incoorect please use following - 
 
@isTest(seeAllData = false)
public class CryptoTestTest{
    
    //Unit Test Method
    static testMethod void unitTest01() {
        
        Account account = new Account();
        account.Name = 'Acc1';
        insert account;
        
        Contact contact = new Contact();
		contact.FirstName = 'con1';
		contact.LastName  = 'test';
		contact.AccountID = account.Id;
		contact.Email = 'abc@gmail.com';
        insert contact;
        
        //Start test method
        test.startTest();
            PageReference pageRef = Page.SendVideoContact; // Your page name
            pageRef.getParameters().put('Id', String.valueOf(contact.Id));
			ApexPages.StandardController sc = new ApexPages.StandardController(contact);//Instance of your object
            CryptoTest  ct = new CryptoTest (sc);
            Test.setCurrentPage(pageRef);
            ct.getFoo();
        //Stop test method
        test.stopTest();
    }
}

 
rupesh ranjanrupesh ranjan
Now this error.  Insert operation is not working
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
caused by: System.QueryException: List has no rows for assignment to SObject

 





    

 
rupesh ranjanrupesh ranjan
actually i want to create a package with above class and VF. but before that we need to create a test class .
So plzz try it on your Org..

Its very urgent fot me
rupesh ranjanrupesh ranjan
check your mail
rupesh ranjanrupesh ranjan
@Tarun have you got my mail?