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 {}
This will generate a corresponding 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()));
 }

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun toString(): String
Link copied to clipboard
abstract fun value(): Class<out Any>
A Component Spec class which is annotated with either LayoutSpec or MountSpec.