Skip to content

Commit

Permalink
Rename demo classes for HierarchicalTestEngine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jul 25, 2016
1 parent 483222d commit 6cf5728
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 86 deletions.
Expand Up @@ -24,7 +24,7 @@

import org.junit.jupiter.api.Test;
import org.junit.platform.console.options.CommandLineOptions;
import org.junit.platform.engine.support.hierarchical.DummyTestEngine;
import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine;

/**
* @since 1.0
Expand All @@ -42,7 +42,7 @@ public void printsSummary() throws Exception {
CommandLineOptions options = new CommandLineOptions();
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("succeedingTest", SUCCEEDING_TEST);
dummyTestEngine.addTest("failingTest", FAILING_BLOCK);

Expand All @@ -61,7 +61,7 @@ public void printsDetailsIfTheyAreNotHidden() throws Exception {
options.setHideDetails(false);
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("failingTest", FAILING_BLOCK);

ExecuteTestsTask task = new ExecuteTestsTask(options, () -> createLauncher(dummyTestEngine));
Expand All @@ -78,7 +78,7 @@ public void printsNoDetailsIfTheyAreHidden() throws Exception {
options.setHideDetails(true);
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("failingTest", FAILING_BLOCK);

ExecuteTestsTask task = new ExecuteTestsTask(options, () -> createLauncher(dummyTestEngine));
Expand All @@ -95,7 +95,7 @@ public void printsFailuresEvenIfDetailsAreHidden() throws Exception {
options.setHideDetails(true);
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("failingTest", FAILING_BLOCK);
dummyTestEngine.addContainer("failingContainer", FAILING_BLOCK);

Expand All @@ -110,7 +110,7 @@ public void hasStatusCode0ForSucceedingTest() throws Exception {
CommandLineOptions options = new CommandLineOptions();
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("succeedingTest", SUCCEEDING_TEST);

ExecuteTestsTask task = new ExecuteTestsTask(options, () -> createLauncher(dummyTestEngine));
Expand All @@ -124,7 +124,7 @@ public void hasStatusCode1ForFailingTest() throws Exception {
CommandLineOptions options = new CommandLineOptions();
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("failingTest", FAILING_BLOCK);

ExecuteTestsTask task = new ExecuteTestsTask(options, () -> createLauncher(dummyTestEngine));
Expand All @@ -138,7 +138,7 @@ public void hasStatusCode1ForFailingContainer() throws Exception {
CommandLineOptions options = new CommandLineOptions();
options.setRunAllTests(true);

DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addContainer("failingContainer", FAILING_BLOCK);

ExecuteTestsTask task = new ExecuteTestsTask(options, () -> createLauncher(dummyTestEngine));
Expand All @@ -155,7 +155,7 @@ public void usesCustomClassLoaderIfAdditionalClassPathEntriesArePresent() throws
options.setAdditionalClasspathEntries(singletonList("."));

ClassLoader oldClassLoader = getDefaultClassLoader();
DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("failingTest",
() -> assertSame(oldClassLoader, getDefaultClassLoader(), "should fail"));

Expand All @@ -173,7 +173,7 @@ public void usesSameClassLoaderIfNoAdditionalClassPathEntriesArePresent() throws
options.setAdditionalClasspathEntries(emptyList());

ClassLoader oldClassLoader = getDefaultClassLoader();
DummyTestEngine dummyTestEngine = new DummyTestEngine();
DemoHierarchicalTestEngine dummyTestEngine = new DemoHierarchicalTestEngine();
dummyTestEngine.addTest("failingTest",
() -> assertNotSame(oldClassLoader, getDefaultClassLoader(), "should fail"));

Expand Down
Expand Up @@ -47,8 +47,8 @@
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.reporting.ReportEntry;
import org.junit.platform.engine.support.descriptor.EngineDescriptor;
import org.junit.platform.engine.support.hierarchical.DummyTestDescriptor;
import org.junit.platform.engine.support.hierarchical.DummyTestEngine;
import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor;
import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine;
import org.junit.platform.engine.test.TestDescriptorStub;
import org.junit.platform.launcher.Launcher;
import org.junit.platform.launcher.TestIdentifier;
Expand All @@ -63,7 +63,7 @@ class XmlReportsWritingListenerTests {

@Test
void writesFileForSingleSucceedingTest(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("succeedingTest", "display<-->Name 😎", () -> {
});

Expand Down Expand Up @@ -95,7 +95,7 @@ void writesFileForSingleSucceedingTest(@Root Path tempDirectory) throws Exceptio

@Test
void writesFileForSingleFailingTest(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("failingTest", () -> fail("expected to <b>fail</b>"));

executeTests(engine, tempDirectory);
Expand All @@ -120,7 +120,7 @@ void writesFileForSingleFailingTest(@Root Path tempDirectory) throws Exception {

@Test
void writesFileForSingleErroneousTest(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("failingTest", () -> {
throw new RuntimeException("error occurred");
});
Expand All @@ -147,8 +147,8 @@ void writesFileForSingleErroneousTest(@Root Path tempDirectory) throws Exception

@Test
void writesFileForSingleSkippedTest(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DummyTestDescriptor testDescriptor = engine.addTest("skippedTest", () -> fail("never called"));
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
DemoHierarchicalTestDescriptor testDescriptor = engine.addTest("skippedTest", () -> fail("never called"));
testDescriptor.markSkipped("should be skipped");

executeTests(engine, tempDirectory);
Expand All @@ -172,7 +172,7 @@ void writesFileForSingleSkippedTest(@Root Path tempDirectory) throws Exception {

@Test
void writesFileForSingleAbortedTest(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("abortedTest", () -> assumeFalse(true, "deliberately aborted"));

executeTests(engine, tempDirectory);
Expand All @@ -198,7 +198,7 @@ void writesFileForSingleAbortedTest(@Root Path tempDirectory) throws Exception {

@Test
void measuresTimesInSeconds(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("firstTest", () -> {
});
engine.addTest("secondTest", () -> {
Expand All @@ -224,7 +224,7 @@ void measuresTimesInSeconds(@Root Path tempDirectory) throws Exception {

@Test
void testWithImmeasurableTimeIsOutputCorrectly(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});

Expand All @@ -242,7 +242,7 @@ void testWithImmeasurableTimeIsOutputCorrectly(@Root Path tempDirectory) throws

@Test
void writesFileForSkippedContainer(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> fail("never called"));
engine.getEngineDescriptor().markSkipped("should be skipped");

Expand All @@ -265,7 +265,7 @@ void writesFileForSkippedContainer(@Root Path tempDirectory) throws Exception {

@Test
void writesFileForFailingContainer(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> fail("never called"));
engine.getEngineDescriptor().setBeforeAllBehavior(() -> fail("failure before all tests"));

Expand All @@ -289,7 +289,7 @@ void writesFileForFailingContainer(@Root Path tempDirectory) throws Exception {

@Test
void writesSystemProperties(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});

Expand All @@ -312,7 +312,7 @@ void writesSystemProperties(@Root Path tempDirectory) throws Exception {

@Test
void writesHostNameAndTimestamp(@Root Path tempDirectory) throws Exception {
DummyTestEngine engine = new DummyTestEngine("dummy");
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});

Expand Down
Expand Up @@ -13,5 +13,5 @@
/**
* @since 1.0
*/
class DummyEngineExecutionContext implements EngineExecutionContext {
class DemoEngineExecutionContext implements EngineExecutionContext {
}
Expand Up @@ -20,17 +20,19 @@
/**
* @since 1.0
*/
public class DummyContainerDescriptor extends AbstractTestDescriptor implements Node<DummyEngineExecutionContext> {
public class DemoHierarchicalContainerDescriptor extends AbstractTestDescriptor
implements Node<DemoEngineExecutionContext> {

private final Runnable beforeBlock;
private String skippedReason;
private boolean skipped;

DummyContainerDescriptor(UniqueId uniqueId, String displayName, Runnable executeBlock) {
DemoHierarchicalContainerDescriptor(UniqueId uniqueId, String displayName, Runnable executeBlock) {
this(uniqueId, displayName, null, executeBlock);
}

public DummyContainerDescriptor(UniqueId uniqueId, String displayName, TestSource source, Runnable beforeBlock) {
public DemoHierarchicalContainerDescriptor(UniqueId uniqueId, String displayName, TestSource source,
Runnable beforeBlock) {
super(uniqueId, displayName);

if (source != null) {
Expand Down Expand Up @@ -65,12 +67,12 @@ public void markSkipped(String reason) {
}

@Override
public SkipResult shouldBeSkipped(DummyEngineExecutionContext context) throws Exception {
public SkipResult shouldBeSkipped(DemoEngineExecutionContext context) throws Exception {
return this.skipped ? skip(this.skippedReason) : doNotSkip();
}

@Override
public DummyEngineExecutionContext before(DummyEngineExecutionContext context) throws Exception {
public DemoEngineExecutionContext before(DemoEngineExecutionContext context) throws Exception {
if (this.beforeBlock != null) {
this.beforeBlock.run();
}
Expand Down
Expand Up @@ -19,14 +19,14 @@
/**
* @since 1.0
*/
public class DummyEngineDescriptor extends EngineDescriptor implements Node<DummyEngineExecutionContext> {
public class DemoHierarchicalEngineDescriptor extends EngineDescriptor implements Node<DemoEngineExecutionContext> {

private String skippedReason;
private boolean skipped;
private Runnable beforeAllBehavior = () -> {
};

public DummyEngineDescriptor(UniqueId uniqueId) {
public DemoHierarchicalEngineDescriptor(UniqueId uniqueId) {
super(uniqueId, uniqueId.getEngineId().get());
}

Expand All @@ -40,12 +40,12 @@ public void setBeforeAllBehavior(Runnable beforeAllBehavior) {
}

@Override
public SkipResult shouldBeSkipped(DummyEngineExecutionContext context) {
public SkipResult shouldBeSkipped(DemoEngineExecutionContext context) {
return skipped ? skip(skippedReason) : doNotSkip();
}

@Override
public DummyEngineExecutionContext before(DummyEngineExecutionContext context) throws Exception {
public DemoEngineExecutionContext before(DemoEngineExecutionContext context) throws Exception {
beforeAllBehavior.run();
return context;
}
Expand Down
Expand Up @@ -20,17 +20,18 @@
/**
* @since 1.0
*/
public class DummyTestDescriptor extends AbstractTestDescriptor implements Node<DummyEngineExecutionContext> {
public class DemoHierarchicalTestDescriptor extends AbstractTestDescriptor implements Node<DemoEngineExecutionContext> {

private final Runnable executeBlock;
private String skippedReason;
private boolean skipped;

DummyTestDescriptor(UniqueId uniqueId, String displayName, Runnable executeBlock) {
DemoHierarchicalTestDescriptor(UniqueId uniqueId, String displayName, Runnable executeBlock) {
this(uniqueId, displayName, null, executeBlock);
}

public DummyTestDescriptor(UniqueId uniqueId, String displayName, TestSource source, Runnable executeBlock) {
public DemoHierarchicalTestDescriptor(UniqueId uniqueId, String displayName, TestSource source,
Runnable executeBlock) {
super(uniqueId, displayName);
if (source != null) {
setSource(source);
Expand Down Expand Up @@ -59,12 +60,12 @@ public void markSkipped(String reason) {
}

@Override
public SkipResult shouldBeSkipped(DummyEngineExecutionContext context) throws Exception {
public SkipResult shouldBeSkipped(DemoEngineExecutionContext context) throws Exception {
return skipped ? skip(skippedReason) : doNotSkip();
}

@Override
public DummyEngineExecutionContext execute(DummyEngineExecutionContext context) {
public DemoEngineExecutionContext execute(DemoEngineExecutionContext context) {
if (this.executeBlock != null) {
this.executeBlock.run();
}
Expand Down

0 comments on commit 6cf5728

Please sign in to comment.