void cleanBefore(@Observes(precedence = 10) Before before) { this.clean(before.getTestClass(), before.getTestMethod(), false); }
public void beforeTest(@Observes(precedence = 100) EventContext<Before> context) { Object inspectionObject = context.getEvent().getTestInstance(); if (!executedInspections.contains(inspectionObject)) { executedInspections.add(inspectionObject); beforeClass.fire(new BeforeClass(inspectionObject.getClass())); } context.proceed(); }
@Override public boolean isTakingAction(Event event) { if (event instanceof Before) { Screenshot screenshotAnnotation = ScreenshotAnnotationScanner.getScreenshotAnnotation(((Before) event).getTestMethod()); if (screenshotAnnotation != null) { return screenshotAnnotation.takeBeforeTest(); } } return false; }
public void enrich(@Observes Before event) throws Exception { Object instance = event.getTestInstance(); Method method = event.getTestMethod(); enrichmentEvent.fire(new BeforeEnrichment(instance, method)); Collection<TestEnricher> testEnrichers = serviceLoader.get().all(TestEnricher.class); for (TestEnricher enricher : testEnrichers) { enricher.enrich(instance); } enrichmentEvent.fire(new AfterEnrichment(instance, method)); } }
/** * <p>The before test event handler.</p> * * <p>Delegates to the registered {@link ApplicationContextProducer} instances in order to create the application * context.</p> * * @param event the before test event */ public void beforeTest(@Observes Before event) { createTestApplicationContext(event.getTestClass()); }
public void before(Object testInstance, Method testMethod, LifecycleMethodExecutor executor) throws Exception { Validate.notNull(testInstance, "TestInstance must be specified"); Validate.notNull(testMethod, "TestMethod must be specified"); ExecutionDecision executionDecision = resolveExecutionDecision(manager, testMethod); if (executionDecision.getDecision() == Decision.DONT_EXECUTE) { return; } manager.fire(new Before(testInstance, testMethod, executor)); }
private boolean hasScreenshotAnnotation(org.jboss.arquillian.core.spi.event.Event event) { if (event instanceof Before) { return ScreenshotAnnotationScanner.getScreenshotAnnotation(((Before) event).getTestMethod()) != null; } else if (event instanceof AfterTestLifecycleEvent) { return ScreenshotAnnotationScanner .getScreenshotAnnotation(((AfterTestLifecycleEvent) event).getTestMethod()) != null; } return false; } }
void sendBefore(@Observes Before event) throws Exception { if (WarpCommons.isWarpTest(event.getTestClass().getJavaClass())) { remoteOperationService().execute(new FireBeforeSuiteOnServer()); } }
@Test public void shouldCallAllEnrichers() throws Exception { Mockito.when(serviceLoader.all(TestEnricher.class)).thenReturn(Arrays.asList(enricher, enricher)); bind(SuiteScoped.class, ServiceLoader.class, serviceLoader); fire(new Before(this, getClass().getMethod("shouldCallAllEnrichers"))); Mockito.verify(enricher, Mockito.times(2)).enrich(this); assertEventFired(BeforeEnrichment.class, 1); assertEventFired(AfterEnrichment.class, 1); } }
void populate(@Observes Before before) { populate(before.getTestClass(), before.getTestMethod()); }
public void registerOnEveryActionInterceptor(@Observes Before event) { BrowserScreenshooterConfiguration configuration = (BrowserScreenshooterConfiguration) this.configuration.get(); Screenshot annotation = event.getTestMethod().getAnnotation(Screenshot.class); if (((annotation != null && annotation.takeOnEveryAction())) || ((annotation == null) && (configuration.getTakeOnEveryAction()))) { registerInterceptor(event); } }
@Test public void shouldCallAllEnrichers() throws Exception { Mockito.when(serviceLoader.all(TestEnricher.class)).thenReturn(Arrays.asList(enricher, enricher)); bind(SuiteScoped.class, ServiceLoader.class, serviceLoader); fire(new Before(this, getClass().getMethod("shouldCallAllEnrichers"))); Mockito.verify(enricher, Mockito.times(2)).enrich(this); assertEventFired(BeforeEnrichment.class, 1); assertEventFired(AfterEnrichment.class, 1); } }
void beforeTest(@Observes(precedence = 500) Before event) { Class<?> testClass = event.getTestInstance().getClass(); if (WarpCommons.isWarpTest(testClass)) { startBus.fire(new StartBus(event)); } }
void cleanBefore(@Observes(precedence = 10) Before before) { this.clean(before.getTestClass(), before.getTestMethod(), false); }
public void registerOnEveryActionInterceptor(@Observes Before event) { BrowserScreenshooterConfiguration configuration = (BrowserScreenshooterConfiguration) this.configuration.get(); Screenshot annotation = event.getTestMethod().getAnnotation(Screenshot.class); if (((annotation != null && annotation.takeOnEveryAction())) || ((annotation == null) && (configuration.getTakeOnEveryAction()))) { registerInterceptor(event); } }
private void executeTest(Object inspection, Method method, List<Annotation> qualifiers) { before.fire(new Before(inspection, method)); test.fire(new Test(new LifecycleMethodExecutor(inspection, method, qualifiers))); after.fire(new After(inspection, method)); }
public void executeBeforeTest(@Observes Before event, TestClass testClass) throws IllegalArgumentException, IllegalAccessException { testInstance = event.getTestInstance(); if (isGetDeployableContainerAnnoPresent) { ContainerManagerTool containerWrapper = new ContainerManagerTool(deployableContainer); setContainer(testInstance, containerWrapper, deployableContainerFields); } }
void cleanBefore(@Observes(precedence = 10) Before before) { this.clean(before.getTestClass(), before.getTestMethod(), false); }
private void registerInterceptor(Before event) { ScreenshotMetaData metaData = getMetaData(event); String screenshotName = getScreenshotName(metaData, When.ON_EVERY_ACTION); Screenshot annotation = event.getTestMethod().getAnnotation(Screenshot.class); TakeScreenshot takeScreenshot = new TakeScreenshot(screenshotName, metaData, When.ON_EVERY_ACTION, annotation); TakeScreenshotOnEveryActionInterceptor onEveryActionInterceptor = new TakeScreenshotOnEveryActionInterceptor(takeScreenshot, getTakeAndReportService(), interceptorRegistry.get()); interceptorRegistry.get().register(onEveryActionInterceptor); } }
@Test public void shouldInvokeBeforeInContainerDeploymentContext() throws Exception { fire(new org.jboss.arquillian.test.spi.event.suite.Before(this, testMethod())); assertEventFiredInContext(org.jboss.arquillian.test.spi.event.suite.Before.class, ContainerContext.class); assertEventFiredInContext(org.jboss.arquillian.test.spi.event.suite.Before.class, DeploymentContext.class); }