Skip to content

Commit 6b799da

Browse files
committed
Merge pull request #7630 from Eddú Meléndez
* gh-7630: Polish "Add TestNG support in TestTypeExcludeFilter" Add TestNG support in TestTypeExcludeFilter Closes gh-7630
2 parents 4d95134 + c04eba7 commit 6b799da

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

spring-boot-project/spring-boot-parent/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<maven-resolver.version>1.1.1</maven-resolver.version>
2828
<spock.version>1.0-groovy-2.4</spock.version>
2929
<testcontainers.version>1.10.6</testcontainers.version>
30+
<testng.version>6.14.3</testng.version>
3031
<dependency-management-plugin.version>1.0.6.RELEASE</dependency-management-plugin.version>
3132
<spring-doc-resources.version>0.1.0.BUILD-SNAPSHOT</spring-doc-resources.version>
3233
</properties>
@@ -246,6 +247,11 @@
246247
<scope>import</scope>
247248
<type>pom</type>
248249
</dependency>
250+
<dependency>
251+
<groupId>org.testng</groupId>
252+
<artifactId>testng</artifactId>
253+
<version>${testng.version}</version>
254+
</dependency>
249255
<dependency>
250256
<groupId>org.zeroturnaround</groupId>
251257
<artifactId>zt-zip</artifactId>

spring-boot-project/spring-boot-test/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@
192192
<artifactId>mockito-kotlin</artifactId>
193193
<scope>test</scope>
194194
</dependency>
195+
<dependency>
196+
<groupId>org.testng</groupId>
197+
<artifactId>testng</artifactId>
198+
<scope>test</scope>
199+
</dependency>
195200
</dependencies>
196201
<build>
197202
<plugins>

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,10 +33,11 @@
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.testng.annotations.Test" };
3737

3838
private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test",
39-
"org.junit.platform.commons.annotation.Testable" };
39+
"org.junit.platform.commons.annotation.Testable",
40+
"org.testng.annotations.Test" };
4041

4142
@Override
4243
public boolean match(MetadataReader metadataReader,
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+
* http://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.testng.annotations.Test;
20+
21+
import org.springframework.context.annotation.Configuration;
22+
23+
@Test
24+
public abstract class AbstractTestNgTestWithConfig {
25+
26+
@Configuration
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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -98,6 +98,14 @@ public void doesNotMatchRegularConfiguration() throws Exception {
9898
this.metadataReaderFactory)).isFalse();
9999
}
100100

101+
@Test
102+
public void matchesNestedConfigurationClassWithoutTestNgAnnotation()
103+
throws Exception {
104+
assertThat(this.filter.match(
105+
getMetadataReader(AbstractTestNgTestWithConfig.Config.class),
106+
this.metadataReaderFactory)).isTrue();
107+
}
108+
101109
private MetadataReader getMetadataReader(Class<?> source) throws IOException {
102110
return this.metadataReaderFactory.getMetadataReader(source.getName());
103111
}

0 commit comments

Comments
 (0)