Commit 6b799da9 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge pull request #7630 from Eddú Meléndez

* gh-7630:
  Polish "Add TestNG support in TestTypeExcludeFilter"
  Add TestNG support in TestTypeExcludeFilter

Closes gh-7630
parents 4d951340 c04eba7e
......@@ -27,6 +27,7 @@
<maven-resolver.version>1.1.1</maven-resolver.version>
<spock.version>1.0-groovy-2.4</spock.version>
<testcontainers.version>1.10.6</testcontainers.version>
<testng.version>6.14.3</testng.version>
<dependency-management-plugin.version>1.0.6.RELEASE</dependency-management-plugin.version>
<spring-doc-resources.version>0.1.0.BUILD-SNAPSHOT</spring-doc-resources.version>
</properties>
......@@ -246,6 +247,11 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
<dependency>
<groupId>org.zeroturnaround</groupId>
<artifactId>zt-zip</artifactId>
......
......@@ -192,6 +192,11 @@
<artifactId>mockito-kotlin</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
......
/*
* Copyright 2012-2018 the original author or authors.
* 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.
......@@ -33,10 +33,11 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
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" };
private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test",
"org.junit.platform.commons.annotation.Testable" };
"org.junit.platform.commons.annotation.Testable",
"org.testng.annotations.Test" };
@Override
public boolean match(MetadataReader metadataReader,
......
/*
* 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
*
* http://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.testng.annotations.Test;
import org.springframework.context.annotation.Configuration;
@Test
public abstract class AbstractTestNgTestWithConfig {
@Configuration
static class Config {
}
}
/*
* Copyright 2012-2018 the original author or authors.
* 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.
......@@ -98,6 +98,14 @@ public class TestTypeExcludeFilterTests {
this.metadataReaderFactory)).isFalse();
}
@Test
public void matchesNestedConfigurationClassWithoutTestNgAnnotation()
throws Exception {
assertThat(this.filter.match(
getMetadataReader(AbstractTestNgTestWithConfig.Config.class),
this.metadataReaderFactory)).isTrue();
}
private MetadataReader getMetadataReader(Class<?> source) throws IOException {
return this.metadataReaderFactory.getMetadataReader(source.getName());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment