|
| 1 | +/* |
| 2 | + * Copyright 2002-2018 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.test.context.junit.jupiter.generics; |
| 18 | + |
| 19 | +import org.junit.jupiter.api.Nested; |
| 20 | + |
| 21 | +import org.springframework.test.context.junit.SpringJUnitJupiterTestSuite; |
| 22 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 23 | +import org.springframework.test.context.junit.jupiter.comics.Cat; |
| 24 | +import org.springframework.test.context.junit.jupiter.comics.Dog; |
| 25 | + |
| 26 | +/** |
| 27 | + * Integration tests that verify support for Java generics combined with {@code @Nested} |
| 28 | + * test classes when used with the Spring TestContext Framework and the |
| 29 | + * {@link SpringExtension}. |
| 30 | + * |
| 31 | + * <p> |
| 32 | + * To run these tests in an IDE that does not have built-in support for the JUnit |
| 33 | + * Platform, simply run {@link SpringJUnitJupiterTestSuite} as a JUnit 4 test. |
| 34 | + * |
| 35 | + * @author Sam Brannen |
| 36 | + * @since 5.0.5 |
| 37 | + */ |
| 38 | +class GenericsAndNestedTestsTestCase { |
| 39 | + |
| 40 | + @Nested |
| 41 | + class CatTestCase extends GenericComicCharactersTestCase<Cat> { |
| 42 | + |
| 43 | + @Override |
| 44 | + int getExpectedNumCharacters() { |
| 45 | + return 2; |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + String getExpectedName() { |
| 50 | + return "Catbert"; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + @Nested |
| 55 | + class DogTestCase extends GenericComicCharactersTestCase<Dog> { |
| 56 | + |
| 57 | + @Override |
| 58 | + int getExpectedNumCharacters() { |
| 59 | + return 1; |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + String getExpectedName() { |
| 64 | + return "Dogbert"; |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | +} |
0 commit comments