Skip to content
Permalink
Browse files

Fixes #685 : Add new method display name pattern for providing compat…

…ibility with pl.pragmatists:JUnitParams before 1.0.6 (#998) [ci maven-central-release]
  • Loading branch information...
baurchanu authored and thekingnothing committed Aug 31, 2019
1 parent 37904cd commit 62b495cc92f130e8a75c5130f2e9b53d8be3ccf5
@@ -47,7 +47,7 @@
}

private static final Pattern methodDisplayNameRgx =
Pattern.compile("^[^\\(\\[]++");
Pattern.compile("(^[^\\(\\[]++)|([^(]+(?=\\)))");
private final Method[] testMethods;
private final List<?> pendingTestInstances;
private final PowerMockTestNotifier powerMockTestNotifier;
@@ -124,6 +124,8 @@ project(":tests:mockito:junit4-delegate") {
exclude group:'org.hamcrest', module:'hamcrest-core'
}

testCompile("pl.pragmatists:JUnitParams:1.0.5")

testCompile files(project(":tests:mockito:junit4").sourceSets.test.output)
}

@@ -0,0 +1,33 @@
package powermock.modules.test.mockito.junit4.delegate;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;

@PowerMockRunnerDelegate(JUnitParamsRunner.class)
@PrepareForTest(Math.class)
@RunWith(PowerMockRunner.class)
public class JUnitParamsTest {

@Before
public void setUp() {
PowerMockito.mockStatic(Math.class);
when(Math.addExact(anyInt(), anyInt())).thenReturn(42);
}

@Test
@Parameters({"11, 234", "-54, 43"})
public void testSum(int a, int b) {
Assert.assertEquals(42, Math.addExact(a, b));
}
}

0 comments on commit 62b495c

Please sign in to comment.
You can’t perform that action at this time.