All Downloads are FREE. Search and download functionalities are using the official Maven repository.

qa.justtestlah.steps.Hooks Maven / Gradle / Ivy

Go to download

JustTestLah! is a JAVA test framework targeting projects that support multiple platforms, in particular Web, Android and iOS. It follows a BDD approach and allows testing against all platforms using the same feature files. JustTestLah's main aim is to make the configuration and the actual test code as easy as possible.

There is a newer version: 1.9-RC4
Show newest version
package qa.justtestlah.steps;

import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import qa.justtestlah.configuration.JustTestLahSpringConfig;
import qa.justtestlah.hooks.CucumberHook;
import qa.justtestlah.hooks.HooksRegister;
import qa.justtestlah.hooks.WebDriverHooks;

/** This class registers Cucumber hooks with {@link HooksRegister}. */
@ContextConfiguration(classes = JustTestLahSpringConfig.class)
public class Hooks {

  @Autowired private HooksRegister hooksRegister;

  @Autowired private WebDriverHooks webDriver;

  private void initHooks() {
    hooksRegister.addHooks(webDriver);
  }

  @Before
  public void notifyBefore(Scenario scenario) {
    initHooks();
    for (CucumberHook hook : hooksRegister.getRegisteredHooks()) {
      hook.before(scenario);
    }
  }

  @After
  public void notifyAfter(Scenario scenario) {
    for (CucumberHook hook : hooksRegister.getRegisteredHooks()) {
      hook.after(scenario);
    }
    hooksRegister.clear();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy