|
13 | 13 | import static java.util.Objects.requireNonNull; |
14 | 14 | import static org.assertj.core.api.Assertions.assertThat; |
15 | 15 | import static org.junit.jupiter.api.TemporaryClasspathExecutor.withAdditionalClasspathRoot; |
| 16 | +import static org.junit.platform.engine.DiscoveryIssue.Severity.INFO; |
16 | 17 | import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; |
17 | 18 | import static org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId; |
18 | 19 | import static org.junit.platform.launcher.TagFilter.excludeTags; |
|
88 | 89 | import org.junit.platform.suite.engine.testsuites.ErroneousTestSuite; |
89 | 90 | import org.junit.platform.suite.engine.testsuites.FailingSuite; |
90 | 91 | import org.junit.platform.suite.engine.testsuites.InheritedSuite; |
| 92 | +import org.junit.platform.suite.engine.testsuites.JupiterDisabledSuite; |
91 | 93 | import org.junit.platform.suite.engine.testsuites.MultiEngineSuite; |
92 | 94 | import org.junit.platform.suite.engine.testsuites.MultipleSuite; |
93 | 95 | import org.junit.platform.suite.engine.testsuites.NestedSuite; |
@@ -591,7 +593,7 @@ void cyclicSuite() { |
591 | 593 | .append(SuiteTestDescriptor.SEGMENT_TYPE, CyclicSuite.class.getName()); |
592 | 594 | var message = "The suite configuration of [%s] resulted in a cycle [%s] and will not be discovered a second time." |
593 | 595 | .formatted(CyclicSuite.class.getName(), expectedUniqueId); |
594 | | - var issue = DiscoveryIssue.builder(Severity.INFO, message) |
| 596 | + var issue = DiscoveryIssue.builder(INFO, message) |
595 | 597 | .source(ClassSource.from(CyclicSuite.class)) |
596 | 598 | .build(); |
597 | 599 |
|
@@ -835,36 +837,52 @@ void validSuiteDisplayNameGeneratesNoWarning() { |
835 | 837 |
|
836 | 838 | @Test |
837 | 839 | void disabledSuite() { |
838 | | - // @formatter:off |
839 | | - EngineTestKit.Builder testKit = EngineTestKit.engine(ENGINE_ID) |
840 | | - .selectors(selectClass(DisabledSuite.class)); |
| 840 | + EngineTestKit.Builder testKit = EngineTestKit.engine(ENGINE_ID) // |
| 841 | + .selectors(selectClass(DisabledSuite.class)) // |
| 842 | + .outputDirectoryCreator(hierarchicalOutputDirectoryCreator(outputDir)); // |
841 | 843 |
|
842 | | - assertThat(testKit.discover().getDiscoveryIssues()) |
| 844 | + assertThat(testKit.discover().getDiscoveryIssues())// |
843 | 845 | .isEmpty(); |
844 | 846 |
|
845 | | - testKit |
846 | | - .execute() |
847 | | - .allEvents() |
848 | | - .assertThatEvents() |
849 | | - .haveExactly(1, event(container(DisabledSuite.class.getName()), skippedWithReason(DisabledSuite.class + " is @Disabled"))); |
850 | | - // @formatter:on |
| 847 | + testKit.execute() // |
| 848 | + .allEvents() // |
| 849 | + .assertThatEvents() // |
| 850 | + .haveExactly(1, event(container(DisabledSuite.class.getName()), |
| 851 | + skippedWithReason(DisabledSuite.class + " is @Disabled"))); |
851 | 852 | } |
852 | 853 |
|
853 | 854 | @Test |
854 | 855 | void disabledSuiteWithReason() { |
855 | | - // @formatter:off |
856 | | - EngineTestKit.Builder testKit = EngineTestKit.engine(ENGINE_ID) |
857 | | - .selectors(selectClass(DisabledWithReasonSuite.class)); |
| 856 | + EngineTestKit.Builder testKit = EngineTestKit.engine(ENGINE_ID).selectors( |
| 857 | + selectClass(DisabledWithReasonSuite.class)) // |
| 858 | + .outputDirectoryCreator(hierarchicalOutputDirectoryCreator(outputDir)); |
858 | 859 |
|
859 | | - assertThat(testKit.discover().getDiscoveryIssues()) |
860 | | - .isEmpty(); |
| 860 | + assertThat(testKit.discover().getDiscoveryIssues()).isEmpty(); |
861 | 861 |
|
862 | | - testKit |
863 | | - .execute() |
864 | | - .allEvents() |
865 | | - .assertThatEvents() |
866 | | - .haveExactly(1, event(container(DisabledWithReasonSuite.class.getName()), skippedWithReason("for testing purposes"))); |
867 | | - // @formatter:on |
| 862 | + testKit.execute() // |
| 863 | + .allEvents() // |
| 864 | + .assertThatEvents() // |
| 865 | + .haveExactly(1, event(container(DisabledWithReasonSuite.class.getName()), |
| 866 | + skippedWithReason("for testing purposes"))); |
| 867 | + } |
| 868 | + |
| 869 | + @Test |
| 870 | + void usingJupiterDisabledLogsAnIssue() { |
| 871 | + var testKit = EngineTestKit.engine(ENGINE_ID).selectors( |
| 872 | + selectClass(JupiterDisabledSuite.class)).outputDirectoryCreator( |
| 873 | + hierarchicalOutputDirectoryCreator(outputDir)); |
| 874 | + |
| 875 | + var expectedIssue = DiscoveryIssue.create(INFO, |
| 876 | + ("The suite [%s] was annotated with [org.junit.jupiter.api.Disabled] which does not disabled the suite. " |
| 877 | + + "Did you mean to use [org.junit.platform.suite.api.Disabled]?") // |
| 878 | + .formatted(JupiterDisabledSuite.class)); |
| 879 | + assertThat(testKit.discover().getDiscoveryIssues()).contains(expectedIssue); |
| 880 | + |
| 881 | + testKit.execute() // |
| 882 | + .testEvents() // |
| 883 | + .assertThatEvents() // |
| 884 | + .haveExactly(1, event(test(JupiterDisabledSuite.class.getName()), finishedSuccessfully())) // |
| 885 | + .haveExactly(1, event(test(SingleTestTestCase.class.getName()), finishedSuccessfully())); |
868 | 886 | } |
869 | 887 |
|
870 | 888 | // ----------------------------------------------------------------------------------------------------------------- |
|
0 commit comments