Dairy supports a unit test runtime, to use it you need to add Dairy’s test fixtures as a test dependency:

Add the newest version of Core found here to the dependencies block:

depdependencies {
	// ...
	testImplementation testFixtures("dev.frozenmilk.dairy:Core:<MAJ.MIN.ENG>")
	// ...
}

Then, you’ll need to set up a unit test source set, and add the org.firstinspires.ftc.teamcode packages.

Test OpModes can be combined with Features to test both that OpModes behave as expected and that Features behave as expected.

Writing an OpMode for testing

This is super useful for library authors working with Dairy.

TestOpMode

@RunWith(OpModeTestRunner.class)
public class IterativeTest extends TestOpMode {
	@Override
	public void init() {
		// do w/e
	}
}

TestLinearOpMode

@RunWith(OpModeTestRunner.class)
public class LinearTest extends TestLinearOpMode {
	@Override
	public void runOpMode() throws InterruptedException {
		// do w/e
	}
}

Running a teamcode OpMode as a test

At the moment this is a bit limited, as there is no direct support for mocking hardware or telemetry, but its possible for you to do this yourself, and support for doing so easily is on the roadmap.

@RunWith(OpModeTestRunner.class)
public class TeamCodeTest extends ExternalTest {
	public TeamCodeTest() {
		// we'll use an OpMode we defined, but we can use one from teamcode
		super(IterativeTest.class);
	}
}

Configuring Test OpModes

Lastly, we can configure OpModes to do things like setup hardware.

public class OpModeConfig extends TestOpModeConfiguration {
	private OpModeConfig() {}
	public static OpModeConfig INSTANCE = new OpModeConfig();
	@Override
	protected void configureOpMode(@NonNull OpMode opMode) {
		opMode.hardwareMap.put("a", (HardwareDevice) null);
	}
}