private org.jboss.arquillian.test.spi.event.suite.Test test(String testMethodName, Object obj) throws Exception { TestMethodExecutor executor = mock(TestMethodExecutor.class); when(executor.getInstance()).thenReturn(obj); when(executor.getMethod()).thenReturn(method(testMethodName)); return new org.jboss.arquillian.test.spi.event.suite.Test( executor ); }
private org.jboss.arquillian.test.spi.event.suite.Test test(String testMethodName, Object obj) throws Exception { TestMethodExecutor executor = mock(TestMethodExecutor.class); when(executor.getInstance()).thenReturn(obj); when(executor.getMethod()).thenReturn(method(testMethodName)); return new org.jboss.arquillian.test.spi.event.suite.Test( executor ); }
@Test(expected = IllegalStateException.class) public void shouldThrowExceptionIfTryingToOperateOnANonExistingContext() throws Exception { fire(new org.jboss.arquillian.test.spi.event.suite.Test(new TestMethodExecutor() { @Override public void invoke(Object... parameters) throws Throwable { } @Override public Method getMethod() { return nonExistingOperatesOnDeploymentMethod(); } @Override public Object getInstance() { return ContainerEventControllerTestCase.this; } })); }
@Test(expected = IllegalStateException.class) public void shouldThrowExceptionIfTryingToOperateOnANonExistingContext() throws Exception { fire(new org.jboss.arquillian.test.spi.event.suite.Test(new TestMethodExecutor() { @Override public void invoke(Object... parameters) throws Throwable { } @Override public Method getMethod() { return nonExistingOperatesOnDeploymentMethod(); } @Override public Object getInstance() { return ContainerEventControllerTestCase.this; } })); }
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 TestResult test(TestMethodExecutor testMethodExecutor) throws Exception { Validate.notNull(testMethodExecutor, "TestMethodExecutor must be specified"); ExecutionDecision executionDecision = resolveExecutionDecision(manager, testMethodExecutor.getMethod()); if (executionDecision.getDecision() == Decision.DONT_EXECUTE) { return TestResult.skipped(new SkippedTestExecutionException(executionDecision.getReason())); } final List<TestResult> results = new ArrayList<TestResult>(); manager.fire(new Test(testMethodExecutor), new NonManagedObserver<Test>() { @Inject private Instance<TestResult> testResult; @Override public void fired(Test event) { results.add(testResult.get()); } }); return TestResult.flatten(results); }
@Test public void shouldInvokeTestInContainerDeploymentContext() throws Exception { fire(new org.jboss.arquillian.test.spi.event.suite.Test(new TestMethodExecutor() { @Override public void invoke(Object... parameters) throws Throwable { } @Override public Method getMethod() { return testMethod(); } @Override public Object getInstance() { return ContainerEventControllerTestCase.this; } })); assertEventFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, ContainerContext.class); assertEventFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, DeploymentContext.class); }
@Test public void shouldInvokeTestInContainerDeploymentContext() throws Exception { fire(new org.jboss.arquillian.test.spi.event.suite.Test(new TestMethodExecutor() { @Override public void invoke(Object... parameters) throws Throwable { } @Override public Method getMethod() { return testMethod(); } @Override public Object getInstance() { return ContainerEventControllerTestCase.this; } })); assertEventFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, ContainerContext.class); assertEventFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, DeploymentContext.class); }
@Test public void shouldNotInvokeTestInContainerDeploymentContextIfNoDeploymentFound() throws Exception { // override previous bound DeploymentScenario with a empty set bind(ClassScoped.class, DeploymentScenario.class, new DeploymentScenario()); fire(new org.jboss.arquillian.test.spi.event.suite.Test(new TestMethodExecutor() { @Override public void invoke(Object... parameters) throws Throwable { } @Override public Method getMethod() { return testMethod(); } @Override public Object getInstance() { return ContainerEventControllerTestCase.this; } })); assertEventNotFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, ContainerContext.class); assertEventNotFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, DeploymentContext.class); }
@Test public void shouldNotInvokeTestInContainerDeploymentContextIfNoDeploymentFound() throws Exception { // override previous bound DeploymentScenario with a empty set bind(ClassScoped.class, DeploymentScenario.class, new DeploymentScenario()); fire(new org.jboss.arquillian.test.spi.event.suite.Test(new TestMethodExecutor() { @Override public void invoke(Object... parameters) throws Throwable { } @Override public Method getMethod() { return testMethod(); } @Override public Object getInstance() { return ContainerEventControllerTestCase.this; } })); assertEventNotFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, ContainerContext.class); assertEventNotFiredInContext(org.jboss.arquillian.test.spi.event.suite.Test.class, DeploymentContext.class); }