Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
#174 Added JavaDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrzyzanowski committed Aug 20, 2018
1 parent fdc4661 commit b4787b6
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
* <br>
* Requires {@code eyes.apiKey} property.
* <br>
* Additional configurable options:
* <ul>
* <li>{@code eyes.fullPageScreenshots} - defines if full-page screenshots should be captured</li>
* </ul>
*/
@ThreadScoped
public class EyesProvider implements Provider<Eyes> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@
import com.google.inject.Inject;
import com.google.inject.name.Named;

/**
* JUnit 4 {@link TestRule} that enables Eyes integration.
* <p>
* Example usage:
* <pre>
* public class ExampleTest {
* &#64;Rule
* &#64;Inject
* public WithEyes withEyes;
*
* public void test() {
* // test actions
* withEyes.getEyes().checkWindow("Example checkpoint");
* }
* }
* </pre>
*/
public class WithEyes implements TestRule {

private final WebDriver webDriver;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <br>
* {@inheritDoc}
*/
@Override
public void beforeEach(ExtensionContext context) throws Exception {
Injector injector = InjectorUtils.retrieveInjectorFromStore(context, NAMESPACE);
Expand All @@ -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.
* <br>
* {@inheritDoc}
*/
@Override
public void afterEach(ExtensionContext context) throws Exception {
Eyes eyes = getEyes(context);
Expand Down

0 comments on commit b4787b6

Please sign in to comment.