Back to Repositories

Implementing Base Test Configuration Framework in Lottie Android

The BaseTest class serves as the foundation for Lottie Android’s test infrastructure, implementing core test configurations using Robolectric for Android environment simulation. This base class establishes essential test parameters and configurations that other test classes can inherit and build upon.

Test Coverage Overview

The test coverage focuses on providing a standardized testing environment for Lottie animations on Android. Key functionality includes:

  • Android P (API 28) SDK version testing
  • Robolectric test runner integration
  • Base configuration for derived test classes
  • Environment simulation for Android components

Implementation Analysis

The testing approach utilizes Robolectric’s testing framework to simulate the Android environment without requiring an emulator or physical device. The implementation leverages JUnit annotations and Robolectric-specific configurations to create an isolated testing environment.

Technical patterns include:
  • @RunWith annotation for Robolectric test runner specification
  • @Config annotation for SDK version configuration
  • @Ignore annotation to prevent direct instantiation

Technical Details

Testing tools and configuration:
  • JUnit testing framework
  • Robolectric test runner
  • Android P SDK (API 28) target
  • Build.VERSION_CODES configuration
  • Base class inheritance structure

Best Practices Demonstrated

The BaseTest class exemplifies several testing best practices in Android development:

  • Centralized test configuration management
  • Clear separation of concerns through base class abstraction
  • Consistent environment configuration across test suite
  • Proper use of testing annotations and configurations
  • Efficient test environment simulation using Robolectric

airbnb/lottie-android

lottie/src/test/java/com/airbnb/lottie/BaseTest.java

            
package com.airbnb.lottie;

import android.os.Build;

import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = Build.VERSION_CODES.P)
@Ignore("Base Test")
public class BaseTest {
}