0

My first test class is passing in Developer Console and in Copado but fails when I deploy. Any suggestions?

Here's the classs

    @isTest
private static void testFetchUser() {
    Test.startTest();
    User testUser = (User) new SObjectBuilder(User.SObjectType, 'Admin')
        .put(User.Email, 'Joe@testuser.com')
        .put(User.Username, 'joe@testuser.com.test')
        .put(User.Subsidiary_Countries__c, 'United States')
        .put(User.Primary_Subsidiary_Country__c, 'United States')
        .put(User.Routing_Group__c, 'IT')
        .createAsAdmin().getRecord();        
    User runUser = ForgotUsernameController.fetchUser('Joe@testuser.com');
    Test.stopTest();
    System.assertEquals(runUser.Username, 'joe@testuser.com.test');
}

And the failure message is

Test failure, method: ForgotUsernameControllerTest.testFetchUser -- System.AssertException: Assertion Failed: Expected: No user found with that email, Actual: joe@testuser.com.hexagonppm stack Class.ForgotUsernameControllerTest.testFetchUser: line 22, column 1
3
  • 1
    2 possible causes - seealldata is true 2nd - some configuration is different in target org.
    – Ysr Shk
    Aug 19 '20 at 14:49
  • The assertion message doesn't agree with the test class. Did you deploy that test class as well as ForgotUserNameController?
    – cropredy
    Aug 19 '20 at 17:46
  • You were correct. Our test environment has different config. Developement is only a partial sandbox.
    – afandre
    Aug 19 '20 at 19:03
0

I found out from my admin that the Development environment is a partial sandbox and the user validations don't match. Thanks for reading this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.