Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore behavior for mocks configured without strictness (#2659)
Fixes #2656
- Loading branch information
1 parent
1fbef57
commit ff98622
Showing
8 changed files
with
179 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2022 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockito; | ||
|
||
import org.junit.Test; | ||
import org.junit.experimental.runners.Enclosed; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import static org.hamcrest.Matchers.not; | ||
import static org.junit.Assume.assumeThat; | ||
|
||
@RunWith(Enclosed.class) | ||
public class MockTest { | ||
|
||
@RunWith(value = Parameterized.class) | ||
public static class StrictnessToMockStrictnessTest { | ||
|
||
public org.mockito.quality.Strictness strictness; | ||
|
||
public StrictnessToMockStrictnessTest(org.mockito.quality.Strictness strictness) { | ||
this.strictness = strictness; | ||
} | ||
|
||
@Test | ||
public void should_have_matching_enum_in_mock_strictness_enum() { | ||
Mock.Strictness.valueOf(strictness.name()); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static org.mockito.quality.Strictness[] data() { | ||
return org.mockito.quality.Strictness.values(); | ||
} | ||
} | ||
|
||
@RunWith(value = Parameterized.class) | ||
public static class MockStrictnessToStrictnessTest { | ||
|
||
public Mock.Strictness strictness; | ||
|
||
public MockStrictnessToStrictnessTest(Mock.Strictness strictness) { | ||
this.strictness = strictness; | ||
} | ||
|
||
@Test | ||
public void should_have_matching_enum_in_strictness_enum() { | ||
assumeThat("Ignore NOT_SET", strictness, not(Mock.Strictness.TEST_LEVEL_DEFAULT)); | ||
org.mockito.quality.Strictness.valueOf(strictness.name()); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Mock.Strictness[] data() { | ||
return Mock.Strictness.values(); | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
subprojects/junit-jupiter/src/test/java/org/mockitousage/ProductionCode.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,15 @@ | ||
/* | ||
* Copyright (c) 2022 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class ProductionCode { | ||
|
||
@SuppressWarnings("ReturnValueIgnored") | ||
public static void simpleMethod(Predicate<String> mock, String argument) { | ||
mock.test(argument); | ||
} | ||
} |
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