Skip to content

Commit ece29bb

Browse files
committed
Merge pull request #18214 from leonard84
* pr/18214: Polish Add Testable to CLASS_ANNOTATIONS in TestTypeExcludeFilter" Add Testable to CLASS_ANNOTATIONS in TestTypeExcludeFilter Closes gh-18214
2 parents b1ca1ae + e05f42f commit ece29bb

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
class TestTypeExcludeFilter extends TypeExcludeFilter {
3434

3535
private static final String[] CLASS_ANNOTATIONS = { "org.junit.runner.RunWith",
36-
"org.junit.jupiter.api.extension.ExtendWith" };
36+
"org.junit.jupiter.api.extension.ExtendWith", "org.junit.platform.commons.annotation.Testable",
37+
"org.testng.annotations.Test", };
3738

3839
private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test",
3940
"org.junit.platform.commons.annotation.Testable" };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.test.context.filter;
18+
19+
import org.junit.platform.commons.annotation.Testable;
20+
21+
import org.springframework.context.annotation.Configuration;
22+
23+
@Testable
24+
public abstract class AbstractJupiterTestWithConfigAndTestable {
25+
26+
@Configuration(proxyBeanMethods = false)
27+
static class Config {
28+
29+
}
30+
31+
}

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasExtendWith()
7979
this.metadataReaderFactory)).isTrue();
8080
}
8181

82+
@Test
83+
public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasTestable() throws Exception {
84+
assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndExtendWith.Config.class),
85+
this.metadataReaderFactory)).isTrue();
86+
}
87+
8288
@Test
8389
public void matchesTestConfiguration() throws Exception {
8490
assertThat(this.filter.match(getMetadataReader(SampleTestConfig.class), this.metadataReaderFactory)).isTrue();

0 commit comments

Comments
 (0)