File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import java .lang .annotation .RetentionPolicy ;
77import java .lang .annotation .Target ;
88
9+ import javax .annotation .Nonnull ;
10+
911/**
1012 * Marker annotation to skip test if it not run with mocks.
1113 *
1517@ Target ({ElementType .METHOD , ElementType .TYPE })
1618@ Inherited
1719public @interface MockOnly {
20+
21+ /**
22+ * Explanation why this test shold only be run with mocks and not against real websites
23+ */
24+ @ Nonnull String reason ();
1825}
Original file line number Diff line number Diff line change @@ -33,13 +33,15 @@ public Statement apply(@Nonnull Statement base, @Nonnull Description description
3333 return new Statement () {
3434 @ Override
3535 public void evaluate () throws Throwable {
36- final boolean hasAnnotation = description .getAnnotation (MockOnly .class ) == null ;
37- final boolean isMockDownloader = downloader == null ||
38- !downloader .equalsIgnoreCase (DownloaderType .REAL .toString ());
39- Assume .assumeTrue (
40- "The test is not reliable against a website and thus skipped" ,
41- hasAnnotation && isMockDownloader
42- );
36+ final MockOnly annotation = description .getAnnotation (MockOnly .class );
37+ if (annotation != null ) {
38+ final boolean isMockDownloader = downloader == null ||
39+ !downloader .equalsIgnoreCase (DownloaderType .REAL .toString ());
40+
41+ Assume .assumeTrue ("The test is not reliable against real website. Reason: "
42+ + annotation .reason (), isMockDownloader );
43+ }
44+
4345
4446 base .evaluate ();
4547 }
You can’t perform that action at this time.
0 commit comments