ApexSensei

Drills Unit testing

Create isolated test data

A test should create the records it needs.

Your task

Finish the two helpers so a test inserts its own Account and reads it back fresh.

@IsTest
public class AS_5E1BF2D4A826_RecordTests {
    public static Account createOwned(String token) {
        Account record = new Account(Name = 'AS Test ' + token, Description = token);
        return record;
    }

    public static Account loadOwned(Id recordId) {
        return null;
    }

    @IsTest
    static void createsAndLoadsData() {
        Account created = createOwned('visible');
        Account loaded = loadOwned(created.Id);
        Assert.areEqual(created.Name, loaded.Name);
    }
}

Requirements

  1. insertsOwnedRecord should pass
  2. preservesOwnedFields should pass
  3. loadsRequestedId should pass
  4. reloadsFreshValues should pass

Sign in to open this drill