-4

I have a test class with this code:

@isTest
public class New_UtilsComplete_Test{

    @testSetup
    static void setupTestData(){
                
        Profile p = [SELECT Id, Name FROM Profile WHERE Name = 'System Administrator'].get(0);  
        
        User u = new User(firstname= 'Test',
        lastname='XXXXx',
        Alias='Test',
        Division_Allocation__c='DL',
        email = 'test1234@test.com',
        username= 'test1234xxx@test.com', 
        profileId= p.Id, 
        emailencodingkey='UTF-8',
        languagelocalekey='en_US',
        localesidkey='en_US',
        timezonesidkey='America/Los_Angeles'
        );
        insert u;
        
        User u1 = new User(firstname= 'Test1',
        lastname='XXXXxY',
        Alias='TestYy',
        Division_Allocation__c='DL',
        Country__c = 'BR',
        email = 'test1234y@test.com',
        username= 'test1234yyy@test.com', 
        profileId= p.Id, 
        emailencodingkey='UTF-8',
        languagelocalekey='en_US',
        localesidkey='en_US',
        timezonesidkey='America/Los_Angeles'
        );
        insert u1;
    }
}

I need to call the two users created on this class into another test class:

@isTest
private class New_Controller_Test{
    @testSetup
    static void setupTestData(){
        test.startTest();
        // Call Profile from New_UtilsComplete_Test Class
        // ...code here

        // Call User1 from New_UtilsComplete_Test Class
        // ...code here

        // Call User2 from New_UtilsComplete_Test Class
        // ...code here

        test.stopTest();
    }
}

How can I do these calls from another class?

Thanks!

0
1

For static methods, just use the class and method name.

New_UtilsComplete_Test.setupTestData();

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