"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/TestClassInheritanceTests.java" between
junit5-r5.3.2.tar.gz and junit5-r5.4.0.tar.gz

About: JUnit 5 is a unit testing framework for the Java programming language.

TestClassInheritanceTests.java  (junit5-r5.3.2):TestClassInheritanceTests.java  (junit5-r5.4.0)
/* /*
* Copyright 2015-2018 the original author or authors. * Copyright 2015-2019 the original author or authors.
* *
* All rights reserved. This program and the accompanying materials are * All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which * made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at * accompanies this distribution and is available at
* *
* http://www.eclipse.org/legal/epl-v20.html * http://www.eclipse.org/legal/epl-v20.html
*/ */
package org.junit.jupiter.engine; package org.junit.jupiter.engine;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectMetho d; import static org.junit.platform.engine.discovery.DiscoverySelectors.selectMetho d;
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.r equest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.platform.engine.test.event.ExecutionEventRecorder; import org.junit.platform.testkit.engine.EngineExecutionResults;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
/** /**
* Integration tests for test class hierarchy support in the {@link JupiterTestE ngine}. * Integration tests for test class hierarchy support in the {@link JupiterTestE ngine}.
* *
* @since 5.0 * @since 5.0
*/ */
class TestClassInheritanceTests extends AbstractJupiterTestEngineTests { class TestClassInheritanceTests extends AbstractJupiterTestEngineTests {
private static final List<String> callSequence = new ArrayList<>(); private static final List<String> callSequence = new ArrayList<>();
skipping to change at line 52 skipping to change at line 50
void initStatics() { void initStatics() {
callSequence.clear(); callSequence.clear();
LocalTestCase.countBeforeInvoked = 0; LocalTestCase.countBeforeInvoked = 0;
LocalTestCase.countAfterInvoked = 0; LocalTestCase.countAfterInvoked = 0;
AbstractTestCase.countSuperBeforeInvoked = 0; AbstractTestCase.countSuperBeforeInvoked = 0;
AbstractTestCase.countSuperAfterInvoked = 0; AbstractTestCase.countSuperAfterInvoked = 0;
} }
@Test @Test
void executeAllTestsInClass() { void executeAllTestsInClass() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(Local TestCase.class); EngineExecutionResults executionResults = executeTestsForClass(Lo calTestCase.class);
assertEquals(6, eventRecorder.getTestStartedCount(), "# tests sta assertEquals(6, executionResults.tests().started().count(), "# te
rted"); sts started");
assertEquals(3, eventRecorder.getTestSuccessfulCount(), "# tests assertEquals(3, executionResults.tests().succeeded().count(), "#
succeeded"); tests succeeded");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests ski assertEquals(0, executionResults.tests().skipped().count(), "# te
pped"); sts skipped");
assertEquals(1, eventRecorder.getTestAbortedCount(), "# tests abo assertEquals(1, executionResults.tests().aborted().count(), "# te
rted"); sts aborted");
assertEquals(2, eventRecorder.getTestFailedCount(), "# tests fail assertEquals(2, executionResults.tests().failed().count(), "# tes
ed"); ts failed");
assertEquals(6, LocalTestCase.countBeforeInvoked, "# before calls "); assertEquals(6, LocalTestCase.countBeforeInvoked, "# before calls ");
assertEquals(6, LocalTestCase.countAfterInvoked, "# after calls") ; assertEquals(6, LocalTestCase.countAfterInvoked, "# after calls") ;
assertEquals(6, AbstractTestCase.countSuperBeforeInvoked, "# supe r before calls"); assertEquals(6, AbstractTestCase.countSuperBeforeInvoked, "# supe r before calls");
assertEquals(6, AbstractTestCase.countSuperAfterInvoked, "# super after calls"); assertEquals(6, AbstractTestCase.countSuperAfterInvoked, "# super after calls");
} }
@Test @Test
void executeSingleTest() { void executeSingleTest() {
LauncherDiscoveryRequest request = request().selectors( EngineExecutionResults executionResults = executeTests(selectMeth
selectMethod(LocalTestCase.class, "alwaysPasses")).build( od(LocalTestCase.class, "alwaysPasses"));
);
ExecutionEventRecorder eventRecorder = executeTests(request); assertEquals(1, executionResults.tests().started().count(), "# te
sts started");
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests sta assertEquals(1, executionResults.tests().succeeded().count(), "#
rted"); tests succeeded");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests assertEquals(0, executionResults.tests().skipped().count(), "# te
succeeded"); sts skipped");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests ski assertEquals(0, executionResults.tests().aborted().count(), "# te
pped"); sts aborted");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests abo assertEquals(0, executionResults.tests().failed().count(), "# tes
rted"); ts failed");
assertEquals(0, eventRecorder.getTestFailedCount(), "# tests fail
ed");
} }
@Test @Test
void executeTestDeclaredInSuperClass() { void executeTestDeclaredInSuperClass() {
LauncherDiscoveryRequest request = request().selectors(selectMeth EngineExecutionResults executionResults = executeTests(selectMeth
od(LocalTestCase.class, "superTest")).build(); od(LocalTestCase.class, "superTest"));
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests sta assertEquals(1, executionResults.tests().started().count(), "# te
rted"); sts started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests assertEquals(1, executionResults.tests().succeeded().count(), "#
succeeded"); tests succeeded");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests ski assertEquals(0, executionResults.tests().skipped().count(), "# te
pped"); sts skipped");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests abo assertEquals(0, executionResults.tests().aborted().count(), "# te
rted"); sts aborted");
assertEquals(0, eventRecorder.getTestFailedCount(), "# tests fail assertEquals(0, executionResults.tests().failed().count(), "# tes
ed"); ts failed");
assertEquals(1, LocalTestCase.countBeforeInvoked, "# after calls" ); assertEquals(1, LocalTestCase.countBeforeInvoked, "# after calls" );
assertEquals(1, LocalTestCase.countAfterInvoked, "# after calls") ; assertEquals(1, LocalTestCase.countAfterInvoked, "# after calls") ;
assertEquals(1, AbstractTestCase.countSuperBeforeInvoked, "# supe r before calls"); assertEquals(1, AbstractTestCase.countSuperBeforeInvoked, "# supe r before calls");
assertEquals(1, AbstractTestCase.countSuperAfterInvoked, "# super after calls"); assertEquals(1, AbstractTestCase.countSuperAfterInvoked, "# super after calls");
} }
@Test @Test
void executeTestWithExceptionThrownInAfterMethod() { void executeTestWithExceptionThrownInAfterMethod() {
LauncherDiscoveryRequest request = request().selectors( EngineExecutionResults executionResults = executeTests(
selectMethod(LocalTestCase.class, "throwExceptionInAfterM selectMethod(LocalTestCase.class, "throwExceptionInAfterM
ethod")).build(); ethod"));
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests sta assertEquals(1, executionResults.tests().started().count(), "# te
rted"); sts started");
assertEquals(0, eventRecorder.getTestSuccessfulCount(), "# tests assertEquals(0, executionResults.tests().succeeded().count(), "#
succeeded"); tests succeeded");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests ski assertEquals(0, executionResults.tests().skipped().count(), "# te
pped"); sts skipped");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests abo assertEquals(0, executionResults.tests().aborted().count(), "# te
rted"); sts aborted");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests fail assertEquals(1, executionResults.tests().failed().count(), "# tes
ed"); ts failed");
} }
@Test @Test
void beforeAndAfterMethodsInTestClassHierarchy() { void beforeAndAfterMethodsInTestClassHierarchy() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestC ase3.class); EngineExecutionResults executionResults = executeTestsForClass(Te stCase3.class);
// @formatter:off // @formatter:off
assertAll( assertAll(
() -> assertEquals(1, eventRecorder.getTestStartedCount() () -> assertEquals(1, executionResults.tests().started().
, "# tests started"), count(), "# tests started"),
() -> assertEquals(1, eventRecorder.getTestSuccessfulCoun () -> assertEquals(1, executionResults.tests().succeeded(
t(), "# tests succeeded"), ).count(), "# tests succeeded"),
() -> assertEquals(0, eventRecorder.getTestSkippedCount() () -> assertEquals(0, executionResults.tests().skipped().
, "# tests skipped"), count(), "# tests skipped"),
() -> assertEquals(0, eventRecorder.getTestAbortedCount() () -> assertEquals(0, executionResults.tests().aborted().
, "# tests aborted"), count(), "# tests aborted"),
() -> assertEquals(0, eventRecorder.getTestFailedCount(), () -> assertEquals(0, executionResults.tests().failed().c
"# tests failed") ount(), "# tests failed")
); );
// @formatter:on // @formatter:on
// @formatter:off // @formatter:off
assertEquals(asList( assertEquals(asList(
"beforeAll1", "beforeAll1",
"beforeAll2", "beforeAll2",
"beforeAll3", "beforeAll3",
"beforeEach1", "beforeEach1",
"beforeEach2", "beforeEach2",
 End of changes. 13 change blocks. 
70 lines changed or deleted 61 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)