public static BitmapSubject assertThat(Bitmap bitmap) { return Truth.assertAbout(FACTORY).that(bitmap); }
@Override void verifyMatch(JavaFileObject refactoredSource, JavaFileObject expectedSource) { assertAbout(javaSource()).that(refactoredSource).parsesAs(expectedSource); } };
@Test public void realObjectWithCorrectType_shouldCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowRealObjectWithCorrectType"; assertAbout(singleClass()) .that(testClass) .compilesWithoutError(); }
@Test public void goodResetter_shouldCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowDummy"; assertAbout(singleClass()) .that(testClass) .compilesWithoutError(); } }
@Test public void realObjectWithNestedClassName_shouldCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowRealObjectWithNestedClassName"; assertAbout(singleClass()) .that(testClass) .compilesWithoutError(); } }
@Test public void value_withUnresolvableClassNameAndOldMaxSdk_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowWithUnresolvableClassNameAndOldMaxSdk"; assertAbout(singleClass()) .that(testClass) .compilesWithoutError(); }
public SingleClassSubject(FailureMetadata failureMetadata, String subject) { super(failureMetadata, subject); source = JavaFileObjects.forResource(Utils.toResourcePath(subject)); tester = assertAbout(javaSources()) .that(ImmutableList.of(source, Utils.SHADOW_EXTRACTOR_SOURCE)) .processedWith(new RobolectricProcessor(DEFAULT_OPTS)); }
@Test public void realObjectWithEmptyImplements_shouldNotRaiseOwnError() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowRealObjectWithEmptyImplements"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withNoErrorContaining("@RealObject"); }
@Test public void realObjectWithEmptyClassName_shouldNotRaiseOwnError() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowRealObjectWithEmptyClassName"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withNoErrorContaining("@RealObject"); }
@Test public void unannotatedSource_shouldCompile() { assertAbout(javaSources()) .that(ImmutableList.of( SHADOW_PROVIDER_SOURCE, SHADOW_EXTRACTOR_SOURCE, forSourceString("HelloWorld", "final class HelloWorld {}"))) .processedWith(new RobolectricProcessor(DEFAULT_OPTS)) .compilesWithoutError(); //.and().generatesNoSources(); Should add this assertion onces // it becomes available in compile-testing }
@Test public void shouldGracefullyHandleUnrecognisedAnnotation() { assertAbout(javaSources()) .that(ImmutableList.of( SHADOW_PROVIDER_SOURCE, SHADOW_EXTRACTOR_SOURCE, forResource("org/robolectric/annotation/TestWithUnrecognizedAnnotation.java"))) .processedWith(new RobolectricProcessor(DEFAULT_OPTS)) .compilesWithoutError(); }
@Test public void realObjectWithCorrectClassName_shouldCompile() { assertAbout(javaSources()) .that(ImmutableList.of( SHADOW_EXTRACTOR_SOURCE, forResource("org/robolectric/annotation/processing/shadows/ShadowRealObjectWithCorrectClassName.java"))) .processedWith(new RobolectricProcessor(DEFAULT_OPTS)) .compilesWithoutError(); }
@Test public void generatedShadowProvider_canConfigureInstrumentingPackages() { Map<String, String> options = new HashMap<>(DEFAULT_OPTS); options.put(SHOULD_INSTRUMENT_PKG_OPT, "false"); assertAbout(javaSources()) .that(ImmutableList.of( SHADOW_PROVIDER_SOURCE, SHADOW_EXTRACTOR_SOURCE, forResource("org/robolectric/annotation/processing/shadows/ShadowDummy.java"))) .processedWith(new RobolectricProcessor(options)) .compilesWithoutError() .and() .generatesSources(forResource("org/robolectric/Robolectric_EmptyProvidedPackageNames.java")); } }
@Test public void generatedFile_shouldComplainAboutNonStaticInnerClasses() { assertAbout(javaSources()) .that(ImmutableList.of( SHADOW_PROVIDER_SOURCE, SHADOW_EXTRACTOR_SOURCE, forResource("org/robolectric/annotation/processing/shadows/ShadowOuterDummyWithErrs.java"))) .processedWith(new RobolectricProcessor(DEFAULT_OPTS)) .failsToCompile() .withErrorContaining("inner shadow classes must be static"); }
@Test public void value_withClassName_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowImplementsDummyWithOuterDummyClassName"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withErrorContaining("@Implements: cannot specify both <value> and <className> attributes") .onLine(6); }
@Test public void realObjectWithTypeMismatch_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowRealObjectWithWrongType"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withErrorContaining("@RealObject with type <com.example.objects.UniqueDummy>; expected <com.example.objects.Dummy>") .onLine(11); }
@Test public void nonPublicResetter_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowResetterNonPublic"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withErrorContaining("@Resetter methods must be public") .onLine(10); }
@Test public void resetterWithParameters_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowResetterWithParameters"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withErrorContaining("@Resetter methods must not have parameters") .onLine(11); }
@Test public void implementsWithoutClassOrClassName_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowImplementsWithoutClass"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withErrorContaining("@Implements: must specify <value> or <className>") .onLine(5); }
@Test public void implementsWithMissingParameters_shouldNotCompile() { final String testClass = "org.robolectric.annotation.processing.shadows.ShadowImplementsWithMissingParameters"; assertAbout(singleClass()) .that(testClass) .failsToCompile() .withErrorContaining("Shadow type is missing type parameters, expected <T,N extends java.lang.Number>") .onLine(7); }