+ Start a Discussion
jbarraza@rocketlawyerjbarraza@rocketlawyer 

Turn off trigger - deploy failing due to errors in test class

Hi All

 

We're trying to turn off a trigger in our Production org and I've tried the following:

 

1.  Make the trigger Inactive in Sandbox

2.  Use the IDE to deploy the trigger to Production

 

The trigger is designed such that it fires on the insert, update, upsert of an Asset.  When the trigger fires, it will call an APEX class to perform th business logic, which is to put the Contact associated to the Asset into a Campaign.   The errors we are getting are due to assertion failures (see code below to see the assertion statements).  It seems like the tests are failing because the trigger is inactive in Sandbox and so it can't fire and therefore can't inititiate the action to put the Contact into the Campaign, and hence the assertion fails?  Does this sound right?  If so, how do I disable a trigger which is a dependency on an active APEX test?

 

 

Here is the Test Class code:

 

@isTest
private class XXXXXXXXX Test {

@isTest(SeeAllData=true) static void testContactGetsAddedToControlGroup() {
List<Asset> getAssets = smbNurtureCampaignTest.setup(1239.0,'Timeshare Lease');

List<CampaignMember> controlCampaignMemeber = [Select id from CampaignMember where Campaign.Name='ProDoc Trial Nurture Control Group' and ContactId=:getAssets[0].ContactId];
System.assert(controlCampaignMemeber.size() == 1);
}

@isTest(SeeAllData=true) static void testContactGetsAddedToTestGroup2Group() {
List<Asset> getAssets = smbNurtureCampaignTest.setup(1230.0,'Timeshare Lease');

List<CampaignMember> testCampaignMemeber = [Select id from CampaignMember where Campaign.Name='ProDoc Trial Nurture Test Group 2' and ContactId=:getAssets[0].ContactId];
System.assert(testCampaignMemeber.size() == 1);
}

 

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
You can't do that without commenting the test classes. From your sandbox. From your sandbox, Comment out the test class, Inactivate trigger and deploy all these together.

All Answers

CaptainObviousCaptainObvious

Try this:

 

1) Open Eclipse
2) Create a new Force.com Project in the Production/Developer Edition Environment
3) Selected metadata components > Choose > Triggers > pick the trigger you want to deactivate
4) Click OK, Finish
5) Navigate to the trigger in the package explorer and double click to open it.
6) Click the Metadata tab (next to the Source tab)
7) Change the <status> to Inactive
8) Right-Click > Save
9) Right-Click > Force.com > Save to Server

jbarraza@rocketlawyerjbarraza@rocketlawyer
Wouldn't this still cause the TestClass to fail since the assertion in the testclass would still evaluate to False. The testclass is included in my previous message and has a dependency on the trigger firing.
Bhawani SharmaBhawani Sharma
You can't do that without commenting the test classes. From your sandbox. From your sandbox, Comment out the test class, Inactivate trigger and deploy all these together.
This was selected as the best answer
jbarraza@rocketlawyerjbarraza@rocketlawyer
Yep... commenting out the test class ended up being the solution. Thanks for the help!