TestSpec
annotation class TestSpec
An interface that is annotated with this annotation will be used to generate a matcher based on the underlying spec. This matcher can in turn be used in tests to verify that mounted components contain certain properties.
For example:
@TestSpec(MyLayoutSpec.class)
public interface TestMyLayoutSpec {}
Content copied to clipboard
TestMyLayout
class which implements the provided interface. It contains a Matcher for the properties of the specified MyLayoutSpec
component spec. This can be used in tests as follows: @Test
public void testMyLayoutSpec() {
final ComponentContext c = mLithoTestRule.getContext();
assertThat(c, mComponent)
.has(subComponentWith(c,
TestMyLayoutSpec.matcher(c)
.title(containsString("My Partial Titl"))
.someOtherProperty(14)
.build()));
}
Content copied to clipboard