-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for BeforeParam and AfterParam
- Loading branch information
1 parent
f35cbd4
commit 948fe8a
Showing
12 changed files
with
900 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
...instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterParam.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,40 @@ | ||
package org.example; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class TestFailedAfterParam { | ||
private final int num1; | ||
private final int num2; | ||
private final int sum; | ||
|
||
public TestFailedAfterParam(final int num1, final int num2, final int sum) { | ||
this.num1 = num1; | ||
this.num2 = num2; | ||
this.sum = sum; | ||
} | ||
|
||
@Parameterized.BeforeParam | ||
public static void setup() {} | ||
|
||
@Parameterized.AfterParam | ||
public static void tearDown() { | ||
throw new RuntimeException("after param setup failed"); | ||
} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][] {{0, 0, 0}, {1, 1, 2}}); | ||
} | ||
|
||
@Test | ||
public void parameterized_test_succeed() { | ||
assertEquals(num1 + num2, sum); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...nstrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeParam.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,40 @@ | ||
package org.example; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class TestFailedBeforeParam { | ||
private final int num1; | ||
private final int num2; | ||
private final int sum; | ||
|
||
public TestFailedBeforeParam(final int num1, final int num2, final int sum) { | ||
this.num1 = num1; | ||
this.num2 = num2; | ||
this.sum = sum; | ||
} | ||
|
||
@Parameterized.BeforeParam | ||
public static void setup() { | ||
throw new RuntimeException("before param setup failed"); | ||
} | ||
|
||
@Parameterized.AfterParam | ||
public static void tearDown() {} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][] {{0, 0, 0}, {1, 1, 2}}); | ||
} | ||
|
||
@Test | ||
public void parameterized_test_succeed() { | ||
assertEquals(num1 + num2, sum); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ion/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeParamAfterParam.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,38 @@ | ||
package org.example; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class TestSucceedBeforeParamAfterParam { | ||
private final int num1; | ||
private final int num2; | ||
private final int sum; | ||
|
||
public TestSucceedBeforeParamAfterParam(final int num1, final int num2, final int sum) { | ||
this.num1 = num1; | ||
this.num2 = num2; | ||
this.sum = sum; | ||
} | ||
|
||
@Parameterized.BeforeParam | ||
public static void setup() {} | ||
|
||
@Parameterized.AfterParam | ||
public static void tearDown() {} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][] {{0, 0, 0}, {1, 1, 2}}); | ||
} | ||
|
||
@Test | ||
public void parameterized_test_succeed() { | ||
assertEquals(num1 + num2, sum); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...umentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/coverages.ftl
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 @@ | ||
[ ] |
Oops, something went wrong.