From b4787b658520fdc7ead9e1cdd7a26d2e99831fd4 Mon Sep 17 00:00:00 2001 From: Michal Krzyzanowski Date: Mon, 20 Aug 2018 11:25:45 +0200 Subject: [PATCH] #174 Added JavaDocs --- .../qa/bb/eyes/guice/EyesModule.java | 3 +++ .../qa/bb/eyes/guice/EyesProvider.java | 10 +++++++ .../cognifide/qa/bb/eyes/junit4/WithEyes.java | 26 +++++++++++++++++++ .../cognifide/qa/bb/eyes/junit5/WithEyes.java | 3 +++ .../qa/bb/eyes/junit5/WithEyesExtension.java | 13 ++++++++++ 5 files changed, 55 insertions(+) diff --git a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesModule.java b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesModule.java index 22194cc1..d013b7ed 100644 --- a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesModule.java +++ b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesModule.java @@ -22,6 +22,9 @@ import com.applitools.eyes.selenium.Eyes; import com.google.inject.AbstractModule; +/** + * Eyes Guice module. Provides an {@link Eyes} instance. + */ public class EyesModule extends AbstractModule { @Override diff --git a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesProvider.java b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesProvider.java index 17cbf691..897bb01d 100644 --- a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesProvider.java +++ b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/guice/EyesProvider.java @@ -25,6 +25,16 @@ import com.google.inject.Provider; import com.google.inject.name.Named; +/** + * Provides a thread-scoped {@link Eyes} instance. Bound in {@link EyesModule}. + *
+ * Requires {@code eyes.apiKey} property. + *
+ * Additional configurable options: + * + */ @ThreadScoped public class EyesProvider implements Provider { diff --git a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit4/WithEyes.java b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit4/WithEyes.java index 00e35b0b..aae80496 100644 --- a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit4/WithEyes.java +++ b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit4/WithEyes.java @@ -29,6 +29,23 @@ import com.google.inject.Inject; import com.google.inject.name.Named; +/** + * JUnit 4 {@link TestRule} that enables Eyes integration. + *

+ * Example usage: + *

+ * public class ExampleTest {
+ *    @Rule
+ *    @Inject
+ *    public WithEyes withEyes;
+ *
+ *    public void test() {
+ *      // test actions
+ *      withEyes.getEyes().checkWindow("Example checkpoint");
+ *    }
+ * }
+ * 
+ */ public class WithEyes implements TestRule { private final WebDriver webDriver; @@ -42,14 +59,23 @@ public WithEyes(WebDriver webDriver, Eyes eyes, @Named("eyes.appName") String ap this.appName = appName; } + /** + * @return the avaialable WebDriver instance + */ public WebDriver getWebDriver() { return webDriver; } + /** + * @return the configured and initialized {@link Eyes} instance. + */ public Eyes getEyes() { return eyes; } + /** + * {@inheritDoc} + */ @Override public Statement apply(Statement base, Description description) { return new Statement() { diff --git a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyes.java b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyes.java index 33cd5560..b898bab4 100644 --- a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyes.java +++ b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyes.java @@ -26,6 +26,9 @@ import org.junit.jupiter.api.extension.ExtendWith; +/** + * Meta-annotation enabling the {@link WithEyesExtension}. + */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @ExtendWith(WithEyesExtension.class) diff --git a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyesExtension.java b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyesExtension.java index 512e10f7..bb0fe7fa 100644 --- a/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyesExtension.java +++ b/bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/junit5/WithEyesExtension.java @@ -34,8 +34,16 @@ import com.google.inject.Injector; import com.google.inject.Key; +/** + * JUnit 5 extension that provides {@link Eyes} capabilities. + */ public class WithEyesExtension implements BeforeEachCallback, AfterEachCallback { + /** + * Opens an {@link Eyes} session before the test. + *
+ * {@inheritDoc} + */ @Override public void beforeEach(ExtensionContext context) throws Exception { Injector injector = InjectorUtils.retrieveInjectorFromStore(context, NAMESPACE); @@ -44,6 +52,11 @@ public void beforeEach(ExtensionContext context) throws Exception { getEyes(context).open(wrappedDriver, String.valueOf(properties.get("eyes.appName")), context.getDisplayName()); } + /** + * Closes or aborts the opened {@link Eyes} session. + *
+ * {@inheritDoc} + */ @Override public void afterEach(ExtensionContext context) throws Exception { Eyes eyes = getEyes(context);