You need to sign in to do that
Don't have an account?
Sharon Ward
Changeset Apex Test Failure
Hi,
I have an inbound Changeset that has failed with the following message:
Apex Test Failures
Class Name: TestTriggerUtility
Method Name: testContactTrigger
Error Message: System.AssertException: Assertion Failed: Expected: 005D0000008twq8IAA, Actual: 005D0000001gINxIAM
Stack Trace: Class.TestTriggerUtility.testContactTrigger: line 40, column 1
I have tried googling this but nothing is very specific. I have no idea what the Trigger Utility is or how to ignore this.
Any help would be appreciated.
I inherited this copy of Salesforce and still trying to find out what all the triggers and classes are for!
I have an inbound Changeset that has failed with the following message:
Apex Test Failures
Class Name: TestTriggerUtility
Method Name: testContactTrigger
Error Message: System.AssertException: Assertion Failed: Expected: 005D0000008twq8IAA, Actual: 005D0000001gINxIAM
Stack Trace: Class.TestTriggerUtility.testContactTrigger: line 40, column 1
I have tried googling this but nothing is very specific. I have no idea what the Trigger Utility is or how to ignore this.
Any help would be appreciated.
I inherited this copy of Salesforce and still trying to find out what all the triggers and classes are for!
The assertion in salesforce is used to test if the expected value is input or not.
Seeing the error, the assetion statement is not getting the value which is expected & thats why the failure.
It will be good if you can post the code.
following link may be similar:
https://success.salesforce.com/answers?id=90630000000ghCDAAY
Regards,
Mayuri
Thanks
Sharon
pls check the following
Class.TestTriggerUtility.testContactTrigger: line 40, column 1
go to class TestTriggerUtility & line 40.
Regards,
Mayuri
We might be able to help you if you can just share the code of the Apex Class with name 'TestTriggerUtility' in your org.
Thanks
There is no code here!
1./**
2 * This class contains unit tests for validating the behavior of Apex classes
3 * and triggers.
4 *
5 * Unit tests are class methods that verify whether a particular piece
6 * of code is working properly. Unit test methods take no arguments,
7 * commit no data to the database, and are flagged with the testMethod
8 * keyword in the method definition.
9 *
10 * All test methods in an organization are executed whenever Apex code is deployed
11 * to a production organization to confirm correctness, ensure code
12 * coverage, and prevent regressions. All Apex classes are
13 * required to have at least 75% code coverage in order to be deployed
14 * to a production organization. In addition, all triggers must have some code coverage.
15 *
16 * The @isTest class annotation indicates this class only contains test
17 * methods. Classes defined with the @isTest annotation do not count against
18 * the organization size limit for all Apex scripts.
19 *
20 * See the Apex Language Reference for more information about Testing and Code Coverage.
21 */
22 @isTest
23 private class TestTriggerUtility {
24
25 static testMethod void testContactTrigger () {
26 // Creating test data
27 Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
28 User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
29 EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
30 LocaleSidKey='en_US', ProfileId = p.Id,
31 TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@tcla.com');
32 insert u;
33
34 Account accInstance = new Account (Name= 'Test', Targeted_By_Lookup__c = u.Id);
35 insert accInstance;
36
37 Contact conInstance = new Contact (LastName='TestCon', AccountId = accInstance.Id, LeadSource = 'Capture/Ringlead',
38 OwnerId = UserInfo.getUserId());
39 insert conInstance;
40 System.assertEquals(u.Id, [SELECT OwnerId FROM Contact WHERE Id =: conInstance.Id].OwnerId);
41 }
42 }
Replace line 37 with the following line in your code:
let me know if it helps.
Thanks!
Thank you for your response. Before I replace the code, please would you be able to tell what this trigger is actually testing and is it needed? I can't quite work out what it's supposed to be doing and wonder if I need it at all? I'm actually trying to delete any contact triggers and have deleted one in my sandbox environment and now trying to put the change set in production without the contact.trigger.
Thanks
Sharon
I cannot comment on the working of your trigger, since I haven't seen your code of that trigger. But I can tell you what this test class is doing.
This test class is creating some mock data:
A standard user profile, A user with that assigned profile, an account with a custom field asscociated with User ID and a contact associated with the account and owner as the User.
And finally, its doing an assertion that User ID is equal to the Contact owner ID.
You can do this two ways.
1. Using workbench. Refer this link for help : http://www.salesforceben.com/way-to-delete-apex-classes-from-production/
2. If you don't want to go through the hassle of using workbench. In your sandox, you can either comment out the whole trigger code or deactivate the trigger and then push the changes to your production.