You need to sign in to do that
Don't have an account?
Sunny G
Code coverage is 100% in Sandbox.. But while deploy to prod. it become 0%??
Hi,
I have a trigger and a test class... the code coverage for trigger is 100% in sandbox.. but when i tried deploying it to production.. it gives an error saying that minimum 1% code coverage for the trigger??? I am noty able to understand why is it so...
Although i tried deploying test class first but it says that the custom object is missing???
I am using Eclipse as well as Setup -> Deploy... for deployment.
The possibility is that when you try to validate the deployment against your production org, it isn't firing the trigger.
Looking at your explanation, do you have the custom object on which the trigger is written in production org?
Post your code including the test class.It might help .
Sales4ce
Hi,
Yes.. it's a new custom object created in sandbox.. and i am trying to deploy it to production. I have the following trigger and for this trigger i have written the following text class...
trigger updaterequestowner on Pre_Sales_Request__c (before insert)
{
Profile auth_profile = [select id from profile where name='HS_StandardUser_Presales'];
Id v_User = UserInfo.GetProfileId();
for(Pre_Sales_Request__c ob : Trigger.new)
{
if(v_User != auth_profile.Id)
{
ob.Request_Owner__c = Userinfo.getUserId();
}
}
}
and i have the following test class :
@isTest
private class TriggerTests {
public static testmethod void testTrigger() {
Pre_Sales_Request__c psrc=new Pre_Sales_Request__c( name = 'a' );
insert psrc;
psrc.name = 'b';
update psrc;
}
}
If you are using eclipse you should be able to use the Project Explorer or Naviagor in eclipse to selec tmore then one file that is the Class and the Test and deploy both at the same time.
1) bring up the Navigator
2) You select the Trigger and the Test File
3) Right Click one of the Files and Force.Com -> Deploy to Server
Just go through the normal process. You can select as many files as you want to update and it will tell you whats new and not.
Hello Sir,
Please help me with the following test class for the following trigger.The code coverage is 66% for that trigger, it should be atleast 75%. pls help...
TEST CLASS:
public class PreSalesRequest_TriggerTest{
public static testmethod void testTrigger1() {
Pre_Sales_Request__c psrc=new Pre_Sales_Request__c( name = 'a' );
insert psrc;
psrc.name = 'b';
update psrc;
Pre_Sales_Request__c updatedName = [SELECT name FROM Pre_Sales_Request__c WHERE Id = :psrc.Id];
System.assertEquals('b', updatedName.name);
}
}
TRIGGER:
trigger change_opps on Pre_Sales_Request__c (before update)
{
for(Pre_Sales_Request__c a:Trigger.new)
{
if(system.trigger.OldMap.get(a.Id).Opportunity__c != system.trigger.NewMap.get(a.Id).Opportunity__c)
{
a.Previous_Stage__c = a.stage__c;
}
}
}
public class PreSalesRequest_TriggerTest{
public static testmethod void testTrigger1() {
Pre_Sales_Request__c psrc=new Pre_Sales_Request__c( name = 'a' );
insert psrc;
psrc.name = 'b';
Opportunity o = [select id from Opportunity limit 1 ];
psrc.Opportunity__c = o.id;
update psrc;
Pre_Sales_Request__c updatedName = [SELECT name FROM Pre_Sales_Request__c WHERE Id = :psrc.Id];
System.assertEquals('b', updatedName.name);
}
}
// You need to test out the opportunity change code. So something like this should work.
Opportunity o = [select id from Opportunity limit 1 ];
psrc.Opportunity__c = o.id;