Commit b005008c authored by Eddú Meléndez's avatar Eddú Meléndez Committed by Andy Wilkinson

Add TestNG support in TestTypeExcludeFilter

See gh-7630
parent 4d951340
...@@ -182,6 +182,7 @@ ...@@ -182,6 +182,7 @@
<statsd-client.version>3.1.0</statsd-client.version> <statsd-client.version>3.1.0</statsd-client.version>
<sun-mail.version>${javax-mail.version}</sun-mail.version> <sun-mail.version>${javax-mail.version}</sun-mail.version>
<saaj-impl.version>1.5.0</saaj-impl.version> <saaj-impl.version>1.5.0</saaj-impl.version>
<testng.version>6.10</testng.version>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf-extras-springsecurity.version>3.0.4.RELEASE</thymeleaf-extras-springsecurity.version> <thymeleaf-extras-springsecurity.version>3.0.4.RELEASE</thymeleaf-extras-springsecurity.version>
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version> <thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
...@@ -2965,6 +2966,11 @@ ...@@ -2965,6 +2966,11 @@
<artifactId>nio-multipart-parser</artifactId> <artifactId>nio-multipart-parser</artifactId>
<version>${nio-multipart-parser.version}</version> <version>${nio-multipart-parser.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.thymeleaf</groupId> <groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId> <artifactId>thymeleaf</artifactId>
......
...@@ -192,6 +192,11 @@ ...@@ -192,6 +192,11 @@
<artifactId>mockito-kotlin</artifactId> <artifactId>mockito-kotlin</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; ...@@ -33,10 +33,11 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
class TestTypeExcludeFilter extends TypeExcludeFilter { class TestTypeExcludeFilter extends TypeExcludeFilter {
private static final String[] CLASS_ANNOTATIONS = { "org.junit.runner.RunWith", 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", 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 @Override
public boolean match(MetadataReader metadataReader, public boolean match(MetadataReader metadataReader,
......
/*
* Copyright 2012-2016 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;
/**
* Abstract test with nest {@code @Configuration} and {@code @Test} used by
* {@link TestTypeExcludeFilter}.
*
* @author Eddú Meléndez
*/
@Test
public abstract class AbstractTestNG {
@Configuration
static class Config {
}
}
...@@ -98,6 +98,13 @@ public class TestTypeExcludeFilterTests { ...@@ -98,6 +98,13 @@ public class TestTypeExcludeFilterTests {
this.metadataReaderFactory)).isFalse(); this.metadataReaderFactory)).isFalse();
} }
@Test
public void matchesNestedConfigurationClassWithoutTestngAnnotation()
throws Exception {
assertThat(this.filter.match(getMetadataReader(AbstractTestNG.Config.class),
this.metadataReaderFactory)).isTrue();
}
private MetadataReader getMetadataReader(Class<?> source) throws IOException { private MetadataReader getMetadataReader(Class<?> source) throws IOException {
return this.metadataReaderFactory.getMetadataReader(source.getName()); 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