From b9c8d7dd60af6a01655a857f34ad72dad9f80b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Thu, 12 Sep 2019 19:19:13 +0200 Subject: [PATCH 1/2] Add Testable to CLASS_ANNOTATIONS in TestTypeExcludeFilter See gh-18214 --- .../boot/test/context/filter/TestTypeExcludeFilter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java index c2240a3388c0..6150f1202112 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java @@ -33,7 +33,8 @@ class TestTypeExcludeFilter extends TypeExcludeFilter { private static final String[] CLASS_ANNOTATIONS = { "org.junit.runner.RunWith", - "org.junit.jupiter.api.extension.ExtendWith" }; + "org.junit.jupiter.api.extension.ExtendWith", "org.testng.annotations.Test", + "org.junit.platform.commons.annotation.Testable"}; private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test", "org.junit.platform.commons.annotation.Testable" }; From e05f42f0f3122ef1248b6e6d8fcb76c6a6885dec Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 16 Sep 2019 09:40:59 +0200 Subject: [PATCH 2/2] Polish Add Testable to CLASS_ANNOTATIONS in TestTypeExcludeFilter" See gh-18214 --- .../context/filter/TestTypeExcludeFilter.java | 4 +-- ...tractJupiterTestWithConfigAndTestable.java | 31 +++++++++++++++++++ .../filter/TestTypeExcludeFilterTests.java | 6 ++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndTestable.java diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java index 6150f1202112..444b97688468 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java @@ -33,8 +33,8 @@ class TestTypeExcludeFilter extends TypeExcludeFilter { private static final String[] CLASS_ANNOTATIONS = { "org.junit.runner.RunWith", - "org.junit.jupiter.api.extension.ExtendWith", "org.testng.annotations.Test", - "org.junit.platform.commons.annotation.Testable"}; + "org.junit.jupiter.api.extension.ExtendWith", "org.junit.platform.commons.annotation.Testable", + "org.testng.annotations.Test", }; private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test", "org.junit.platform.commons.annotation.Testable" }; diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndTestable.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndTestable.java new file mode 100644 index 000000000000..5e81cf1a82e9 --- /dev/null +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndTestable.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.context.filter; + +import org.junit.platform.commons.annotation.Testable; + +import org.springframework.context.annotation.Configuration; + +@Testable +public abstract class AbstractJupiterTestWithConfigAndTestable { + + @Configuration(proxyBeanMethods = false) + static class Config { + + } + +} diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java index 529f27b42cbf..43c1d637d029 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java @@ -79,6 +79,12 @@ public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasExtendWith() this.metadataReaderFactory)).isTrue(); } + @Test + public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasTestable() throws Exception { + assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndExtendWith.Config.class), + this.metadataReaderFactory)).isTrue(); + } + @Test public void matchesTestConfiguration() throws Exception { assertThat(this.filter.match(getMetadataReader(SampleTestConfig.class), this.metadataReaderFactory)).isTrue();