use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method abortInLeafExecute.
@Test
void abortInLeafExecute() throws Exception {
MyLeaf child = spy(new MyLeaf(UniqueId.root("leaf", "leaf")));
TestAbortedException anAbortedException = new TestAbortedException("in test");
when(child.execute(eq(rootContext), any())).thenThrow(anAbortedException);
root.addChild(child);
InOrder inOrder = inOrder(listener, root, child);
executor.execute();
ArgumentCaptor<TestExecutionResult> childExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(root).before(rootContext);
inOrder.verify(listener).executionStarted(child);
inOrder.verify(child).execute(eq(rootContext), any());
inOrder.verify(listener).executionFinished(eq(child), childExecutionResult.capture());
inOrder.verify(root).after(rootContext);
inOrder.verify(listener).executionFinished(eq(root), any(TestExecutionResult.class));
assertThat(childExecutionResult.getValue().getStatus()).isEqualTo(ABORTED);
assertThat(childExecutionResult.getValue().getThrowable()).containsSame(anAbortedException);
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method rootDescriptorWithOneChildContainer.
@Test
void rootDescriptorWithOneChildContainer() throws Exception {
MyContainer child = spy(new MyContainer(UniqueId.root("container", "child container")));
root.addChild(child);
InOrder inOrder = inOrder(listener, root, child);
executor.execute();
ArgumentCaptor<TestExecutionResult> childExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(child).prepare(rootContext);
inOrder.verify(child).shouldBeSkipped(rootContext);
inOrder.verify(listener).executionStarted(child);
inOrder.verify(child).before(rootContext);
inOrder.verify(child).after(rootContext);
inOrder.verify(listener).executionFinished(eq(child), childExecutionResult.capture());
inOrder.verify(listener).executionFinished(eq(root), any(TestExecutionResult.class));
assertThat(childExecutionResult.getValue().getStatus()).isEqualTo(SUCCESSFUL);
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method rootDescriptorWithOneChildLeaf.
@Test
void rootDescriptorWithOneChildLeaf() throws Exception {
MyLeaf child = spy(new MyLeaf(UniqueId.root("leaf", "child leaf")));
root.addChild(child);
InOrder inOrder = inOrder(listener, root, child);
executor.execute();
ArgumentCaptor<TestExecutionResult> aTestExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(child).prepare(rootContext);
inOrder.verify(child).shouldBeSkipped(rootContext);
inOrder.verify(listener).executionStarted(child);
inOrder.verify(child).execute(eq(rootContext), any());
inOrder.verify(listener).executionFinished(eq(child), aTestExecutionResult.capture());
inOrder.verify(listener).executionFinished(eq(root), any(TestExecutionResult.class));
assertThat(aTestExecutionResult.getValue().getStatus()).isEqualTo(SUCCESSFUL);
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method emptyRootDescriptor.
@Test
void emptyRootDescriptor() throws Exception {
InOrder inOrder = inOrder(listener, root);
executor.execute();
ArgumentCaptor<TestExecutionResult> rootExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
inOrder.verify(root).prepare(rootContext);
inOrder.verify(root).shouldBeSkipped(rootContext);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(root).before(rootContext);
inOrder.verify(root).after(rootContext);
inOrder.verify(listener).executionFinished(eq(root), rootExecutionResult.capture());
assertThat(rootExecutionResult.getValue().getStatus()).isEqualTo(SUCCESSFUL);
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method exceptionInLeafExecute.
@Test
void exceptionInLeafExecute() throws Exception {
MyLeaf child = spy(new MyLeaf(UniqueId.root("leaf", "leaf")));
RuntimeException anException = new RuntimeException("in test");
when(child.execute(eq(rootContext), any())).thenThrow(anException);
root.addChild(child);
InOrder inOrder = inOrder(listener, root, child);
executor.execute();
ArgumentCaptor<TestExecutionResult> childExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(root).before(rootContext);
inOrder.verify(listener).executionStarted(child);
inOrder.verify(child).execute(eq(rootContext), any());
inOrder.verify(listener).executionFinished(eq(child), childExecutionResult.capture());
inOrder.verify(root).after(rootContext);
inOrder.verify(listener).executionFinished(eq(root), any(TestExecutionResult.class));
assertThat(childExecutionResult.getValue().getStatus()).isEqualTo(FAILED);
assertThat(childExecutionResult.getValue().getThrowable()).containsSame(anException);
}
Aggregations