Skip to content

Commit

Permalink
Introduce test for test execution based on test ID
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Oct 29, 2015
1 parent e95e5eb commit d5f3be3
Showing 1 changed file with 28 additions and 2 deletions.
Expand Up @@ -31,10 +31,14 @@
public class JUnit5TestEngineTests {

@org.junit.Test
public void executeTestsFromDescriptorsGeneratedFromClasses() {
public void executeTestsFromFromClasses() {
JUnit5TestEngine engine = new JUnit5TestEngine();

TestPlanSpecification spec = TestPlanSpecification.builder().classes(LocalTestCase.class).build();
// @formatter:off
TestPlanSpecification spec = TestPlanSpecification.builder()
.classes(LocalTestCase.class)
.build();
// @formatter:on

List<TestDescriptor> descriptors = engine.discoverTests(spec);
Assert.assertNotNull(descriptors);
Expand All @@ -50,6 +54,28 @@ public void executeTestsFromDescriptorsGeneratedFromClasses() {
Assert.assertEquals(1, listener.testFailedCount.get());
}

@org.junit.Test
public void executeTestFromTestId() {
JUnit5TestEngine engine = new JUnit5TestEngine();

// @formatter:off
TestPlanSpecification spec = TestPlanSpecification.builder()
.uniqueIds("junit5:org.junit.gen5.engine.junit5.JUnit5TestEngineTests$LocalTestCase#alwaysPasses()")
.build();
// @formatter:on

List<TestDescriptor> descriptors = engine.discoverTests(spec);
Assert.assertNotNull(descriptors);
Assert.assertEquals("# tests", 1, descriptors.size());

TrackingTestExecutionListener listener = new TrackingTestExecutionListener();

engine.execute(descriptors, listener);

Assert.assertEquals(1, listener.testStartedCount.get());
Assert.assertEquals(1, listener.testSucceededCount.get());
}


private static class LocalTestCase {

Expand Down

0 comments on commit d5f3be3

Please sign in to comment.