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

qa.justtestlah.base.Base 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.base;

import java.lang.reflect.Field;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Base class for all Spring managed pages and step definitions
 *
 * 

We inject all page objects. This way it is not necessary to annotate them with {@link * org.springframework.beans.factory.annotation.Autowired}. */ public class Base implements ApplicationContextAware { private static final Logger LOG = LoggerFactory.getLogger(Base.class); private ApplicationContext applicationContext; /** * inject the page objects (without using @org.springframework.beans.factory.annotation.Autowired * annotations) */ @PostConstruct @SuppressWarnings("squid:S3011") public void initPages() { LOG.info("Initializing page objects for class {}", this.getClass()); Class clazz = this.getClass(); while (clazz != Base.class) { for (Field field : clazz.getDeclaredFields()) { if (BasePage.class.isAssignableFrom(field.getType())) { field.setAccessible(true); try { LOG.debug("Loading page object {} of type {}", field.getName(), field.getType()); field.set(this, applicationContext.getBean(field.getType())); } catch (BeansException | IllegalArgumentException | IllegalAccessException exception) { LOG.error("Error initializing page objects for class {}", this.getClass()); LOG.error("Exception", exception); } } } clazz = clazz.getSuperclass(); } } @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy