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
pull/18464/head
Stephane Nicoll 5 years ago
commit ece29bbdfc

@ -33,7 +33,8 @@ 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.junit.platform.commons.annotation.Testable",
"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" };

@ -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 {
}
}

@ -79,6 +79,12 @@ public class TestTypeExcludeFilterTests {
this.metadataReaderFactory)).isTrue(); this.metadataReaderFactory)).isTrue();
} }
@Test
public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasTestable() throws Exception {
assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndExtendWith.Config.class),
this.metadataReaderFactory)).isTrue();
}
@Test @Test
public void matchesTestConfiguration() throws Exception { public void matchesTestConfiguration() throws Exception {
assertThat(this.filter.match(getMetadataReader(SampleTestConfig.class), this.metadataReaderFactory)).isTrue(); assertThat(this.filter.match(getMetadataReader(SampleTestConfig.class), this.metadataReaderFactory)).isTrue();

Loading…
Cancel
Save