"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "platform-tests/src/test/java/org/junit/platform/runner/JUnitPlatformRunnerTests.java" between
junit5-r5.3.2.tar.gz and junit5-r5.4.0.tar.gz

About: JUnit 5 is a unit testing framework for the Java programming language.

JUnitPlatformRunnerTests.java  (junit5-r5.3.2):JUnitPlatformRunnerTests.java  (junit5-r5.4.0)
/* /*
* Copyright 2015-2018 the original author or authors. * Copyright 2015-2019 the original author or authors.
* *
* All rights reserved. This program and the accompanying materials are * All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which * made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at * accompanies this distribution and is available at
* *
* http://www.eclipse.org/legal/epl-v20.html * http://www.eclipse.org/legal/epl-v20.html
*/ */
package org.junit.platform.runner; package org.junit.platform.runner;
skipping to change at line 69 skipping to change at line 69
import org.junit.platform.engine.discovery.PackageNameFilter; import org.junit.platform.engine.discovery.PackageNameFilter;
import org.junit.platform.engine.discovery.PackageSelector; import org.junit.platform.engine.discovery.PackageSelector;
import org.junit.platform.engine.discovery.UniqueIdSelector; import org.junit.platform.engine.discovery.UniqueIdSelector;
import org.junit.platform.engine.support.descriptor.AbstractTestDescriptor; import org.junit.platform.engine.support.descriptor.AbstractTestDescriptor;
import org.junit.platform.engine.support.descriptor.ClassSource; import org.junit.platform.engine.support.descriptor.ClassSource;
import org.junit.platform.engine.support.descriptor.EngineDescriptor; import org.junit.platform.engine.support.descriptor.EngineDescriptor;
import org.junit.platform.engine.support.descriptor.MethodSource; import org.junit.platform.engine.support.descriptor.MethodSource;
import org.junit.platform.engine.support.hierarchical.DemoHierarchicalContainerD escriptor; import org.junit.platform.engine.support.hierarchical.DemoHierarchicalContainerD escriptor;
import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescri ptor; import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescri ptor;
import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine ; import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine ;
import org.junit.platform.engine.test.TestDescriptorStub; import org.junit.platform.fakes.TestDescriptorStub;
import org.junit.platform.engine.test.TestEngineStub; import org.junit.platform.fakes.TestEngineStub;
import org.junit.platform.launcher.EngineFilter; import org.junit.platform.launcher.EngineFilter;
import org.junit.platform.launcher.Launcher; import org.junit.platform.launcher.Launcher;
import org.junit.platform.launcher.LauncherDiscoveryRequest; import org.junit.platform.launcher.LauncherDiscoveryRequest;
import org.junit.platform.launcher.PostDiscoveryFilter; import org.junit.platform.launcher.PostDiscoveryFilter;
import org.junit.platform.launcher.TestPlan; import org.junit.platform.launcher.TestPlan;
import org.junit.platform.suite.api.ExcludeClassNamePatterns; import org.junit.platform.suite.api.ExcludeClassNamePatterns;
import org.junit.platform.suite.api.ExcludeEngines; import org.junit.platform.suite.api.ExcludeEngines;
import org.junit.platform.suite.api.ExcludePackages; import org.junit.platform.suite.api.ExcludePackages;
import org.junit.platform.suite.api.ExcludeTags; import org.junit.platform.suite.api.ExcludeTags;
import org.junit.platform.suite.api.IncludeClassNamePatterns; import org.junit.platform.suite.api.IncludeClassNamePatterns;
skipping to change at line 106 skipping to change at line 106
* Tests for the {@link JUnitPlatform} runner. * Tests for the {@link JUnitPlatform} runner.
* *
* @since 1.0 * @since 1.0
*/ */
class JUnitPlatformRunnerTests { class JUnitPlatformRunnerTests {
@Nested @Nested
class Discovery { class Discovery {
@Test @Test
void requestsClassSelectorForAnnotatedClassWhenNoAdditionalAnnota tionsArePresent() throws Exception { void requestsClassSelectorForAnnotatedClassWhenNoAdditionalAnnota tionsArePresent() {
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassSelector> selectors = request.getSelectorsByTyp e(ClassSelector.class); List<ClassSelector> selectors = request.getSelectorsByTyp e(ClassSelector.class);
assertThat(selectors).hasSize(1); assertThat(selectors).hasSize(1);
ClassSelector classSelector = getOnlyElement(selectors); ClassSelector classSelector = getOnlyElement(selectors);
assertEquals(TestCase.class, classSelector.getJavaClass() ); assertEquals(TestCase.class, classSelector.getJavaClass() );
} }
@Test @Test
void requestsClassSelectorsWhenSelectClassesAnnotationIsPresent() throws Exception { void requestsClassSelectorsWhenSelectClassesAnnotationIsPresent() {
@SelectClasses({ Short.class, Byte.class }) @SelectClasses({ Short.class, Byte.class })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassSelector> selectors = request.getSelectorsByTyp e(ClassSelector.class); List<ClassSelector> selectors = request.getSelectorsByTyp e(ClassSelector.class);
assertThat(selectors).hasSize(2); assertThat(selectors).hasSize(2);
assertEquals(Short.class, selectors.get(0).getJavaClass() ); assertEquals(Short.class, selectors.get(0).getJavaClass() );
assertEquals(Byte.class, selectors.get(1).getJavaClass()) ; assertEquals(Byte.class, selectors.get(1).getJavaClass()) ;
} }
@Test @Test
void requestsPackageSelectorsWhenPackagesAnnotationIsPresent() th rows Exception { void requestsPackageSelectorsWhenPackagesAnnotationIsPresent() {
@SelectPackages({ "foo", "bar" }) @SelectPackages({ "foo", "bar" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PackageSelector> selectors = request.getSelectorsByT ype(PackageSelector.class); List<PackageSelector> selectors = request.getSelectorsByT ype(PackageSelector.class);
assertThat(selectors).hasSize(2); assertThat(selectors).hasSize(2);
assertEquals("foo", selectors.get(0).getPackageName()); assertEquals("foo", selectors.get(0).getPackageName());
assertEquals("bar", selectors.get(1).getPackageName()); assertEquals("bar", selectors.get(1).getPackageName());
} }
@Test @Test
void addsPackageFiltersToRequestWhenIncludePackageAnnotationIsPre sent() throws Exception { void addsPackageFiltersToRequestWhenIncludePackageAnnotationIsPre sent() {
@IncludePackages({ "includedpackage1", "includedpackage2" }) @IncludePackages({ "includedpackage1", "includedpackage2" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PackageNameFilter> filters = request.getFiltersByTyp e(PackageNameFilter.class); List<PackageNameFilter> filters = request.getFiltersByTyp e(PackageNameFilter.class);
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
PackageNameFilter filter = filters.get(0); PackageNameFilter filter = filters.get(0);
assertTrue(filter.apply("includedpackage1.TestClass").inc luded()); assertTrue(filter.apply("includedpackage1.TestClass").inc luded());
assertTrue(filter.apply("includedpackage2.TestClass").inc luded()); assertTrue(filter.apply("includedpackage2.TestClass").inc luded());
assertTrue(filter.apply("excludedpackage1.TestClass").exc luded()); assertTrue(filter.apply("excludedpackage1.TestClass").exc luded());
} }
@Test @Test
void addsPackageFiltersToRequestWhenExcludePackageAnnotationIsPre sent() throws Exception { void addsPackageFiltersToRequestWhenExcludePackageAnnotationIsPre sent() {
@ExcludePackages({ "excludedpackage1", "excludedpackage2" }) @ExcludePackages({ "excludedpackage1", "excludedpackage2" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PackageNameFilter> filters = request.getFiltersByTyp e(PackageNameFilter.class); List<PackageNameFilter> filters = request.getFiltersByTyp e(PackageNameFilter.class);
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
PackageNameFilter filter = filters.get(0); PackageNameFilter filter = filters.get(0);
assertTrue(filter.apply("includedpackage1.TestClass").inc luded()); assertTrue(filter.apply("includedpackage1.TestClass").inc luded());
assertTrue(filter.apply("excludedpackage1.TestClass").exc luded()); assertTrue(filter.apply("excludedpackage1.TestClass").exc luded());
assertTrue(filter.apply("excludedpackage2.TestClass").exc luded()); assertTrue(filter.apply("excludedpackage2.TestClass").exc luded());
} }
@Test @Test
void addsTagFilterToRequestWhenIncludeTagsAnnotationIsPresent() t hrows Exception { void addsTagFilterToRequestWhenIncludeTagsAnnotationIsPresent() {
@IncludeTags({ "foo", "bar" }) @IncludeTags({ "foo", "bar" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters(); List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters();
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
PostDiscoveryFilter filter = filters.get(0); PostDiscoveryFilter filter = filters.get(0);
assertTrue(filter.apply(testDescriptorWithTags("foo")).in cluded()); assertTrue(filter.apply(testDescriptorWithTags("foo")).in cluded());
assertTrue(filter.apply(testDescriptorWithTags("bar")).in cluded()); assertTrue(filter.apply(testDescriptorWithTags("bar")).in cluded());
assertTrue(filter.apply(testDescriptorWithTags("baz")).ex cluded()); assertTrue(filter.apply(testDescriptorWithTags("baz")).ex cluded());
} }
@Test @Test
void addsTagFilterToRequestWhenExcludeTagsAnnotationIsPresent() t hrows Exception { void addsTagFilterToRequestWhenExcludeTagsAnnotationIsPresent() {
@ExcludeTags({ "foo", "bar" }) @ExcludeTags({ "foo", "bar" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters(); List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters();
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
PostDiscoveryFilter filter = filters.get(0); PostDiscoveryFilter filter = filters.get(0);
assertTrue(filter.apply(testDescriptorWithTags("foo")).ex cluded()); assertTrue(filter.apply(testDescriptorWithTags("foo")).ex cluded());
assertTrue(filter.apply(testDescriptorWithTags("bar")).ex cluded()); assertTrue(filter.apply(testDescriptorWithTags("bar")).ex cluded());
assertTrue(filter.apply(testDescriptorWithTags("baz")).in cluded()); assertTrue(filter.apply(testDescriptorWithTags("baz")).in cluded());
} }
@Test @Test
void includeTagsAcceptsTagExpressions() throws Exception { void includeTagsAcceptsTagExpressions() {
@IncludeTags("foo & !bar") @IncludeTags("foo & !bar")
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters(); List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters();
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
PostDiscoveryFilter filter = filters.get(0); PostDiscoveryFilter filter = filters.get(0);
assertTrue(filter.apply(testDescriptorWithTags("foo")).in cluded()); assertTrue(filter.apply(testDescriptorWithTags("foo")).in cluded());
assertTrue(filter.apply(testDescriptorWithTags("foo", "an y_other_tag")).included()); assertTrue(filter.apply(testDescriptorWithTags("foo", "an y_other_tag")).included());
assertTrue(filter.apply(testDescriptorWithTags("foo", "ba r")).excluded()); assertTrue(filter.apply(testDescriptorWithTags("foo", "ba r")).excluded());
assertTrue(filter.apply(testDescriptorWithTags("bar")).ex cluded()); assertTrue(filter.apply(testDescriptorWithTags("bar")).ex cluded());
assertTrue(filter.apply(testDescriptorWithTags("bar", "an y_other_tag")).excluded()); assertTrue(filter.apply(testDescriptorWithTags("bar", "an y_other_tag")).excluded());
} }
@Test @Test
void excludeTagsAcceptsTagExpressions() throws Exception { void excludeTagsAcceptsTagExpressions() {
@ExcludeTags("foo & !bar") @ExcludeTags("foo & !bar")
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters(); List<PostDiscoveryFilter> filters = request.getPostDiscov eryFilters();
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
PostDiscoveryFilter filter = filters.get(0); PostDiscoveryFilter filter = filters.get(0);
assertTrue(filter.apply(testDescriptorWithTags("foo")).ex cluded()); assertTrue(filter.apply(testDescriptorWithTags("foo")).ex cluded());
assertTrue(filter.apply(testDescriptorWithTags("foo", "an y_other_tag")).excluded()); assertTrue(filter.apply(testDescriptorWithTags("foo", "an y_other_tag")).excluded());
assertTrue(filter.apply(testDescriptorWithTags("foo", "ba r")).included()); assertTrue(filter.apply(testDescriptorWithTags("foo", "ba r")).included());
assertTrue(filter.apply(testDescriptorWithTags("bar")).in cluded()); assertTrue(filter.apply(testDescriptorWithTags("bar")).in cluded());
assertTrue(filter.apply(testDescriptorWithTags("bar", "an y_other_tag")).included()); assertTrue(filter.apply(testDescriptorWithTags("bar", "an y_other_tag")).included());
} }
@Test @Test
void addsEngineFiltersToRequestWhenIncludeEnginesOrExcludeEngines AnnotationsArePresent() throws Exception { void addsEngineFiltersToRequestWhenIncludeEnginesOrExcludeEngines AnnotationsArePresent() {
@IncludeEngines({ "foo", "bar", "baz" }) @IncludeEngines({ "foo", "bar", "baz" })
@ExcludeEngines({ "bar", "quux" }) @ExcludeEngines({ "bar", "quux" })
class TestCase { class TestCase {
} }
TestEngine fooEngine = new TestEngineStub("foo"); TestEngine fooEngine = new TestEngineStub("foo");
TestEngine barEngine = new TestEngineStub("bar"); TestEngine barEngine = new TestEngineStub("bar");
TestEngine bazEngine = new TestEngineStub("baz"); TestEngine bazEngine = new TestEngineStub("baz");
TestEngine quuxEngine = new TestEngineStub("quux"); TestEngine quuxEngine = new TestEngineStub("quux");
skipping to change at line 293 skipping to change at line 293
assertTrue(includeFilter.apply(quuxEngine).excluded()); assertTrue(includeFilter.apply(quuxEngine).excluded());
EngineFilter excludeFilter = filters.get(1); EngineFilter excludeFilter = filters.get(1);
assertTrue(excludeFilter.apply(fooEngine).included()); assertTrue(excludeFilter.apply(fooEngine).included());
assertTrue(excludeFilter.apply(barEngine).excluded()); assertTrue(excludeFilter.apply(barEngine).excluded());
assertTrue(excludeFilter.apply(bazEngine).included()); assertTrue(excludeFilter.apply(bazEngine).included());
assertTrue(excludeFilter.apply(quuxEngine).excluded()); assertTrue(excludeFilter.apply(quuxEngine).excluded());
} }
@Test @Test
void addsDefaultClassNameFilterToRequestWhenFilterClassNameAnnota void addsDefaultClassNameFilterToRequestWhenFilterClassNameAnnota
tionIsNotPresentOnTestSuite() tionIsNotPresentOnTestSuite() {
throws Exception {
@SelectPackages("foo") @SelectPackages("foo")
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(S TANDARD_INCLUDE_PATTERN); assertThat(getOnlyElement(filters).toString()).contains(S TANDARD_INCLUDE_PATTERN);
} }
@Test @Test
void addsDefaultClassNameFilterToRequestWhenFilterClassNameAnnota void addsDefaultClassNameFilterToRequestWhenFilterClassNameAnnota
tionIsNotPresentOnTestClass() tionIsNotPresentOnTestClass() {
throws Exception {
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(filters).isEmpty(); assertThat(filters).isEmpty();
} }
@Test @Test
void addsSingleExplicitClassNameFilterToRequestWhenIncludeClassNa void addsSingleExplicitClassNameFilterToRequestWhenIncludeClassNa
mePatternsAnnotationIsPresent() mePatternsAnnotationIsPresent() {
throws Exception {
@IncludeClassNamePatterns(".*Foo") @IncludeClassNamePatterns(".*Foo")
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(" .*Foo"); assertThat(getOnlyElement(filters).toString()).contains(" .*Foo");
} }
@Test @Test
void addsSingleClassNameFilterToRequestWhenExcludeClassNamePatter nsAnnotationIsPresent() throws Exception { void addsSingleClassNameFilterToRequestWhenExcludeClassNamePatter nsAnnotationIsPresent() {
@ExcludeClassNamePatterns(".*Foo") @ExcludeClassNamePatterns(".*Foo")
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(" .*Foo"); assertThat(getOnlyElement(filters).toString()).contains(" .*Foo");
} }
@Test @Test
void addsMultipleExplicitClassNameFilterToRequestWhenIncludeClass void addsMultipleExplicitClassNameFilterToRequestWhenIncludeClass
NamePatternsAnnotationIsPresent() NamePatternsAnnotationIsPresent() {
throws Exception {
@IncludeClassNamePatterns({ ".*Foo", "Bar.*" }) @IncludeClassNamePatterns({ ".*Foo", "Bar.*" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(" .*Foo", "Bar.*"); assertThat(getOnlyElement(filters).toString()).contains(" .*Foo", "Bar.*");
} }
@Test @Test
void addsMultipleClassNameFilterToRequestWhenExcludeClassNamePatt ernsAnnotationIsPresent() throws Exception { void addsMultipleClassNameFilterToRequestWhenExcludeClassNamePatt ernsAnnotationIsPresent() {
@ExcludeClassNamePatterns({ ".*Foo", "Bar.*" }) @ExcludeClassNamePatterns({ ".*Foo", "Bar.*" })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(" .*Foo", "Bar.*"); assertThat(getOnlyElement(filters).toString()).contains(" .*Foo", "Bar.*");
} }
@Test @Test
void usesStandardIncludePatternWhenIncludeClassNamePatternsAnnota void usesStandardIncludePatternWhenIncludeClassNamePatternsAnnota
tionIsPresentWithoutArguments() tionIsPresentWithoutArguments() {
throws Exception {
@IncludeClassNamePatterns @IncludeClassNamePatterns
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(S TANDARD_INCLUDE_PATTERN); assertThat(getOnlyElement(filters).toString()).contains(S TANDARD_INCLUDE_PATTERN);
} }
@Test @Test
void doesNotAddClassNameFilterWhenIncludeClassNamePatternsAnnotat void doesNotAddClassNameFilterWhenIncludeClassNamePatternsAnnotat
ionIsPresentWithEmptyArguments() ionIsPresentWithEmptyArguments() {
throws Exception {
@IncludeClassNamePatterns({}) @IncludeClassNamePatterns({})
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(filters).isEmpty(); assertThat(filters).isEmpty();
} }
@Test @Test
void doesNotAddClassNameFilterWhenExcludeClassNamePatternsAnnotat void doesNotAddClassNameFilterWhenExcludeClassNamePatternsAnnotat
ionIsPresentWithEmptyArguments() ionIsPresentWithEmptyArguments() {
throws Exception {
@ExcludeClassNamePatterns({}) @ExcludeClassNamePatterns({})
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(filters).isEmpty(); assertThat(filters).isEmpty();
} }
@Test @Test
void trimsArgumentsOfIncludeClassNamePatternsAnnotation() throws Exception { void trimsArgumentsOfIncludeClassNamePatternsAnnotation() {
@IncludeClassNamePatterns({ " foo", "bar " }) @IncludeClassNamePatterns({ " foo", "bar " })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(" 'foo'", "'bar'"); assertThat(getOnlyElement(filters).toString()).contains(" 'foo'", "'bar'");
} }
@Test @Test
void trimsArgumentsOfExcludeClassNamePatternsAnnotation() throws Exception { void trimsArgumentsOfExcludeClassNamePatternsAnnotation() {
@ExcludeClassNamePatterns({ " foo", "bar " }) @ExcludeClassNamePatterns({ " foo", "bar " })
class TestCase { class TestCase {
} }
LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class); LauncherDiscoveryRequest request = instantiateRunnerAndCa ptureGeneratedRequest(TestCase.class);
List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class); List<ClassNameFilter> filters = request.getFiltersByType( ClassNameFilter.class);
assertThat(getOnlyElement(filters).toString()).contains(" 'foo'", "'bar'"); assertThat(getOnlyElement(filters).toString()).contains(" 'foo'", "'bar'");
} }
@Test @Test
void convertsTestIdentifiersIntoDescriptions() throws Exception { void convertsTestIdentifiersIntoDescriptions() {
TestDescriptor container1 = new TestDescriptorStub(Unique Id.root("root", "container1"), "container1"); TestDescriptor container1 = new TestDescriptorStub(Unique Id.root("root", "container1"), "container1");
container1.addChild(new TestDescriptorStub(UniqueId.root( "root", "test1"), "test1")); container1.addChild(new TestDescriptorStub(UniqueId.root( "root", "test1"), "test1"));
TestDescriptor container2 = new TestDescriptorStub(Unique Id.root("root", "container2"), "container2"); TestDescriptor container2 = new TestDescriptorStub(Unique Id.root("root", "container2"), "container2");
container2.addChild(new TestDescriptorStub(UniqueId.root( "root", "test2a"), "test2a")); container2.addChild(new TestDescriptorStub(UniqueId.root( "root", "test2a"), "test2a"));
container2.addChild(new TestDescriptorStub(UniqueId.root( "root", "test2b"), "test2b")); container2.addChild(new TestDescriptorStub(UniqueId.root( "root", "test2b"), "test2b"));
TestPlan testPlan = TestPlan.from(asList(container1, cont ainer2)); TestPlan testPlan = TestPlan.from(asList(container1, cont ainer2));
Launcher launcher = mock(Launcher.class); Launcher launcher = mock(Launcher.class);
when(launcher.discover(any())).thenReturn(testPlan); when(launcher.discover(any())).thenReturn(testPlan);
skipping to change at line 511 skipping to change at line 504
assertEquals("[root:leaf2b]", getOnlyElement(uniqueIdSele ctors).getUniqueId().toString()); assertEquals("[root:leaf2b]", getOnlyElement(uniqueIdSele ctors).getUniqueId().toString());
Description parentDescription = getOnlyElement(runner.get Description().getChildren()); Description parentDescription = getOnlyElement(runner.get Description().getChildren());
assertEquals(suiteDescription("[root:parent2]"), parentDe scription); assertEquals(suiteDescription("[root:parent2]"), parentDe scription);
Description testDescription = getOnlyElement(parentDescri ption.getChildren()); Description testDescription = getOnlyElement(parentDescri ption.getChildren());
assertEquals(testDescription("[root:leaf2b]"), testDescri ption); assertEquals(testDescription("[root:leaf2b]"), testDescri ption);
} }
@Test @Test
void throwsNoTestsRemainExceptionWhenNoTestIdentifierMatchesFilte r() throws Exception { void throwsNoTestsRemainExceptionWhenNoTestIdentifierMatchesFilte r() {
TestPlan testPlan = TestPlan.from(singleton(new TestDescr iptorStub(UniqueId.root("root", "test"), "test"))); TestPlan testPlan = TestPlan.from(singleton(new TestDescr iptorStub(UniqueId.root("root", "test"), "test")));
Launcher launcher = mock(Launcher.class); Launcher launcher = mock(Launcher.class);
when(launcher.discover(any())).thenReturn(testPlan); when(launcher.discover(any())).thenReturn(testPlan);
JUnitPlatform runner = new JUnitPlatform(TestClass.class, launcher); JUnitPlatform runner = new JUnitPlatform(TestClass.class, launcher);
assertThrows(NoTestsRemainException.class, assertThrows(NoTestsRemainException.class,
() -> runner.filter(matchMethodDescription(suiteD escription("[root:doesNotExist]")))); () -> runner.filter(matchMethodDescription(suiteD escription("[root:doesNotExist]"))));
} }
skipping to change at line 625 skipping to change at line 618
verifyNoMoreInteractions(runListener); verifyNoMoreInteractions(runListener);
} }
} }
@Nested @Nested
class Descriptions { class Descriptions {
@Test @Test
@DisplayName("Suite with default display name") @DisplayName("Suite with default display name")
void descriptionForTestSuiteWithDefaultDisplayName() throws Excep tion { void descriptionForTestSuiteWithDefaultDisplayName() {
Class<?> testClass = TestSuiteWithDefaultDisplayName.clas s; Class<?> testClass = TestSuiteWithDefaultDisplayName.clas s;
JUnitPlatform platformRunner = new JUnitPlatform(testClas s, JUnitPlatform platformRunner = new JUnitPlatform(testClas s,
createLauncher(new DemoHierarchicalTestEngine("su ite names"))); createLauncher(new DemoHierarchicalTestEngine("su ite names")));
assertEquals(testClass.getName(), platformRunner.getDescr iption().getDisplayName()); assertEquals(testClass.getName(), platformRunner.getDescr iption().getDisplayName());
} }
@Test @Test
@DisplayName("Suite with @SuiteDisplayName") @DisplayName("Suite with @SuiteDisplayName")
void descriptionForTestSuiteWithCustomDisplayName() throws Except ion { void descriptionForTestSuiteWithCustomDisplayName() {
JUnitPlatform platformRunner = new JUnitPlatform(TestSuit eWithCustomDisplayName.class, JUnitPlatform platformRunner = new JUnitPlatform(TestSuit eWithCustomDisplayName.class,
createLauncher(new DemoHierarchicalTestEngine("su ite names"))); createLauncher(new DemoHierarchicalTestEngine("su ite names")));
assertEquals("Sweeeeeeet Name!", platformRunner.getDescri ption().getDisplayName()); assertEquals("Sweeeeeeet Name!", platformRunner.getDescri ption().getDisplayName());
} }
@Test @Test
@DisplayName("Suite with @SuiteDisplayName and @UseTechnicalNames ") @DisplayName("Suite with @SuiteDisplayName and @UseTechnicalNames ")
void descriptionForTestSuiteWithCustomDisplayNameAndTechnicalName s() throws Exception { void descriptionForTestSuiteWithCustomDisplayNameAndTechnicalName s() {
Class<?> testClass = TestSuiteWithCustomDisplayNameAndTec hnicalNames.class; Class<?> testClass = TestSuiteWithCustomDisplayNameAndTec hnicalNames.class;
JUnitPlatform platformRunner = new JUnitPlatform(testClas s, JUnitPlatform platformRunner = new JUnitPlatform(testClas s,
createLauncher(new DemoHierarchicalTestEngine("su ite names"))); createLauncher(new DemoHierarchicalTestEngine("su ite names")));
assertEquals(testClass.getName(), platformRunner.getDescr iption().getDisplayName()); assertEquals(testClass.getName(), platformRunner.getDescr iption().getDisplayName());
} }
@Test @Test
void descriptionForJavaMethodAndClassSources() throws Exception { void descriptionForJavaMethodAndClassSources() throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalT estEngine("dummy"); DemoHierarchicalTestEngine engine = new DemoHierarchicalT estEngine("dummy");
 End of changes. 28 change blocks. 
43 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)