Skip to content

Commit

Permalink
fixup! Fixes #2626 : Introduce MockSettings.mockMaker
Browse files Browse the repository at this point in the history
  • Loading branch information
JojOatXGME committed Sep 3, 2022
1 parent 337cb79 commit 7ad0472
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/mockito/internal/util/MockUtil.java
Expand Up @@ -49,9 +49,9 @@ private static MockMaker getMockMaker(String mockMaker) {
}

Class<? extends MockMaker> type;
// TODO: #2701 I doubt that it is a good idea to use the context class loader here,
// but PluginInitializer.loadImpl is using it as well,
// but DefaultMockitoPlugins.create is explicitly not using it.
// Using the context class loader because PluginInitializer.loadImpl is using it as well.
// Personally, I am suspicious whether the context class loader is a good choice in either
// of these cases.
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = ClassLoader.getSystemClassLoader();
Expand Down
Expand Up @@ -259,10 +259,10 @@ public int compare(Constructor<?> constructorA, Constructor<?> constructorB) {
private int countMockableParams(Constructor<?> constructor) {
int constructorMockableParamsSize = 0;
for (Class<?> aClass : constructor.getParameterTypes()) {
// TODO: #2701 I don't really understand the reason for this check here.
// It looks like we are not actually creating any mocks for these
// parameters, but might only use mocks which are already created
// and stored in some fields.
// The argResolver already knows the concrete types it can provide.
// Instead of checking for mockability, I think it would be better to
// ask the argResolver whether it can resolve this type.
// Anyway, I keep it for now to avoid breaking any existing code.
if (MockUtil.typeMockabilityOf(aClass, null).mockable()) {
constructorMockableParamsSize++;
}
Expand Down

0 comments on commit 7ad0472

Please sign in to comment.