-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use suite events for more accurate reporting (#2985)
In 4.13 testSuiteStarted/Finished were introduced. While top-level test class events were already reported at the appropriate time, events for intermediate levels such as iterations of the `Parameterized` runner or classes executed by the `Suite` runner were created synthetically when the first test was started and the last test was finished, respectively.
- Loading branch information
1 parent
5fdb138
commit be55668
Showing
8 changed files
with
281 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...estFixtures/java/org/junit/vintage/engine/samples/junit4/ParameterizedTimingTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2015-2022 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.vintage.engine.samples.junit4; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.time.Instant; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.AfterParam; | ||
import org.junit.runners.Parameterized.BeforeParam; | ||
import org.junit.runners.Parameterized.Parameter; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
/** | ||
* @since 5.9 | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class ParameterizedTimingTestCase { | ||
|
||
public static Map<String, Instant> EVENTS = new LinkedHashMap<>(); | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
EVENTS.clear(); | ||
} | ||
|
||
@BeforeParam | ||
public static void beforeParam(String param) throws Exception { | ||
EVENTS.put("beforeParam(" + param + ")", Instant.now()); | ||
Thread.sleep(100); | ||
} | ||
|
||
@AfterParam | ||
public static void afterParam(String param) throws Exception { | ||
Thread.sleep(100); | ||
System.out.println("ParameterizedTimingTestCase.afterParam"); | ||
EVENTS.put("afterParam(" + param + ")", Instant.now()); | ||
} | ||
|
||
@Parameters(name = "{0}") | ||
public static Iterable<String> parameters() { | ||
return List.of("foo", "bar"); | ||
} | ||
|
||
@Parameter | ||
public String value; | ||
|
||
@Test | ||
public void test() { | ||
assertEquals("foo", value); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...a/org/junit/vintage/engine/samples/junit4/ParameterizedWithAfterParamFailureTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2015-2022 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.vintage.engine.samples.junit4; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.AfterParam; | ||
import org.junit.runners.Parameterized.Parameter; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
/** | ||
* @since 5.9 | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class ParameterizedWithAfterParamFailureTestCase { | ||
|
||
@AfterParam | ||
public static void afterParam() { | ||
fail(); | ||
} | ||
|
||
@Parameters(name = "{0}") | ||
public static Iterable<String> parameters() { | ||
return List.of("foo", "bar"); | ||
} | ||
|
||
@Parameter | ||
public String value; | ||
|
||
@Test | ||
public void test() { | ||
assertEquals("foo", value); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
.../org/junit/vintage/engine/samples/junit4/ParameterizedWithBeforeParamFailureTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2015-2022 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.vintage.engine.samples.junit4; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.BeforeParam; | ||
import org.junit.runners.Parameterized.Parameter; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
/** | ||
* @since 5.9 | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class ParameterizedWithBeforeParamFailureTestCase { | ||
|
||
@BeforeParam | ||
public static void beforeParam() { | ||
fail(); | ||
} | ||
|
||
@Parameters(name = "{0}") | ||
public static Iterable<String> parameters() { | ||
return List.of("foo", "bar"); | ||
} | ||
|
||
@Parameter | ||
public String value; | ||
|
||
@Test | ||
public void test() { | ||
assertEquals("foo", value); | ||
} | ||
|
||
} |