Litho provides a variety of tools for automated testing. This page aims to give a brief overview of the different concepts and show you where to go to learn more.
Litho provides a suite of helpers to make unit testing easier. Learn about the setup with our JUnit Rules and AssertJ helpers in Unit Testing Basics.
A common way to test components is by looking at the tree they generate and make assertions over its children. Sub-Component Matching lays out the concepts and APIs for writing declarative matchers against your component trees.
Once you know how to test for sub-components, you can learn about more advanced techniques for verifying props on them in the Matching Props guide.
Litho provides a pluggable mechanism for dependency injection. This tutorial
shows you how to test props which were injected via
Testing Event Handlers
Event handlers are just like any other prop you would set on your component. That means you can use the mechanisms you’ve learned before with Sub-Component Testing. Find an example on how to use this in the Event Handler Testing guide.
For testing Sections, we have a few helpers, including
SubSection which are explained in detail
under Unit Testing Sections.
We offer an optional package for writing end-to-end tests with Espresso. Learn more in the Espresso section.
Lastly, if you want to run unit tests in Android Studio, you currently have to jump through some hoops as loading native code is not well supported by the IDE. Follow the guide to get set up.