ApexSensei

Drills Unit testing

Build a test data factory

A test data factory is a public @IsTest class with helpers that build records for many tests.

Your task

Finish the factory so it builds, inserts and returns the requested Accounts with one DML statement.

@IsTest
public class AS_3C368617D776_DataFactory {
    public static List<Account> createAccounts(Integer count, String token) {
        List<Account> records = new List<Account>();
        return records;
    }

    @IsTest
    static void createsThreeAccounts() {
        List<Account> records = createAccounts(3, 'visible');
        Assert.areEqual(3, records.size());
    }
}

Requirements

  1. createsRequestedCount should pass
  2. assignsNumberedNames should pass
  3. handlesSmallestCounts should pass
  4. returnsInsertedIds should pass
  5. insertsWithOneStatement should pass

Sign in to open this drill