diff --git a/spring-boot-test/pom.xml b/spring-boot-test/pom.xml
index e4011bd9c461..77934e5e2358 100644
--- a/spring-boot-test/pom.xml
+++ b/spring-boot-test/pom.xml
@@ -167,6 +167,11 @@
spring-webmvc
test
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java
index 803436ca7323..98f324520acc 100644
--- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java
+++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 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.
@@ -28,12 +28,15 @@
* well as inner-classes of tests.
*
* @author Phillip Webb
+ * @author Andy Wilkinson
*/
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" };
- private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test" };
+ private static final String[] METHOD_ANNOTATIONS = { "org.junit.Test",
+ "org.junit.platform.commons.annotation.Testable", };
@Override
public boolean match(MetadataReader metadataReader,
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndExtendWith.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndExtendWith.java
new file mode 100644
index 000000000000..238f2633adc8
--- /dev/null
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/AbstractJupiterTestWithConfigAndExtendWith.java
@@ -0,0 +1,32 @@
+/*
+ * 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.junit.jupiter.api.extension.ExtendWith;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+public abstract class AbstractJupiterTestWithConfigAndExtendWith {
+
+ @Configuration
+ static class Config {
+
+ }
+
+}
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterRepeatedTestExample.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterRepeatedTestExample.java
new file mode 100644
index 000000000000..4b55dfa2edf7
--- /dev/null
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterRepeatedTestExample.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012-2017 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.junit.jupiter.api.RepeatedTest;
+
+public class JupiterRepeatedTestExample {
+
+ @RepeatedTest(5)
+ public void repeatedTest() {
+
+ }
+
+}
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterTestExample.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterTestExample.java
new file mode 100644
index 000000000000..0956f4f59988
--- /dev/null
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterTestExample.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012-2017 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.junit.jupiter.api.Test;
+
+public class JupiterTestExample {
+
+ @Test
+ public void repeatedTest() {
+
+ }
+
+}
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterTestFactoryExample.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterTestFactoryExample.java
new file mode 100644
index 000000000000..995c8dfe1ef0
--- /dev/null
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/JupiterTestFactoryExample.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2012-2017 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 java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.jupiter.api.DynamicNode;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+
+public class JupiterTestFactoryExample {
+
+ @TestFactory
+ public Collection testFactory() {
+ return Arrays.asList(DynamicTest.dynamicTest("Some dynamic test", () -> {
+ // Test
+ }));
+ }
+
+}
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java
index 38e555e5841d..20f52b9d9956 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 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.
@@ -31,6 +31,7 @@
* Tests for {@link TestTypeExcludeFilter}.
*
* @author Phillip Webb
+ * @author Andy Wilkinson
*/
public class TestTypeExcludeFilterTests {
@@ -39,11 +40,29 @@ public class TestTypeExcludeFilterTests {
private MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
@Test
- public void matchesTestClass() throws Exception {
+ public void matchesJUnit4TestClass() throws Exception {
assertThat(this.filter.match(getMetadataReader(TestTypeExcludeFilterTests.class),
this.metadataReaderFactory)).isTrue();
}
+ @Test
+ public void matchesJUnitJupiterTestClass() throws Exception {
+ assertThat(this.filter.match(getMetadataReader(JupiterTestExample.class),
+ this.metadataReaderFactory)).isTrue();
+ }
+
+ @Test
+ public void matchesJUnitJupiterRepeatedTestClass() throws Exception {
+ assertThat(this.filter.match(getMetadataReader(JupiterRepeatedTestExample.class),
+ this.metadataReaderFactory)).isTrue();
+ }
+
+ @Test
+ public void matchesJUnitJupiterTestFactoryClass() throws Exception {
+ assertThat(this.filter.match(getMetadataReader(JupiterTestFactoryExample.class),
+ this.metadataReaderFactory)).isTrue();
+ }
+
@Test
public void matchesNestedConfiguration() throws Exception {
assertThat(this.filter.match(getMetadataReader(NestedConfig.class),
@@ -58,6 +77,15 @@ public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasRunWith()
this.metadataReaderFactory)).isTrue();
}
+ @Test
+ public void matchesNestedConfigurationClassWithoutTestMethodsIfItHasExtendWith()
+ throws Exception {
+ assertThat(this.filter.match(
+ getMetadataReader(
+ AbstractJupiterTestWithConfigAndExtendWith.Config.class),
+ this.metadataReaderFactory)).isTrue();
+ }
+
@Test
public void matchesTestConfiguration() throws Exception {
assertThat(this.filter.match(getMetadataReader(SampleTestConfig.class),