defective test case `ProcessorChainTest.noFailureDoesNotTriggerEarlyExit`
agebhar1 opened this issue · 0 comments
agebhar1 commented
From Mockito 1.9(.5) any
Matcher:
This method don't do any type checks, it is only there to avoid casting in your code. This might however change (type checks could be added) in a future major release.
If the test case noFailureDoesNotTriggerEarlyExit checks with isNotNull
instead of any
diff --git a/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java b/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java
index 072ad8b..13ea6ef 100644
--- a/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java
+++ b/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java
@@ -117,8 +117,8 @@ public final class ProcessorChainTest
processor.process(report, input);
- verify(p1).process(same(report), any(MessageProvider.class));
- verify(p2).process(same(report), any(MessageProvider.class));
+ verify(p1).process(same(report), isNotNull(MessageProvider.class));
+ verify(p2).process(same(report), isNotNull(MessageProvider.class));
}
it fails with:
[TestEventLogger] Gradle test > com.github.fge.jsonschema.core.processing.ProcessorChainTest.noFailureDoesNotTriggerEarlyExit FAILED
[TestEventLogger] Argument(s) are different! Wanted:
[TestEventLogger] processor.process(
[TestEventLogger] same(com.github.fge.jsonschema.core.processing.ProcessorChainTest.DummyReport: success
[TestEventLogger] ),
[TestEventLogger] notNull()
[TestEventLogger] );
[TestEventLogger] -> at com.github.fge.jsonschema.core.processing.ProcessorChainTest.noFailureDoesNotTriggerEarlyExit(ProcessorChainTest.java:121)
[TestEventLogger] Actual invocation has different arguments:
[TestEventLogger] processor.process(
[TestEventLogger] com.github.fge.jsonschema.core.processing.ProcessorChainTest.DummyReport: success
[TestEventLogger] ,
[TestEventLogger] null
[TestEventLogger] );
[TestEventLogger] -> at com.github.fge.jsonschema.core.processing.ProcessorChain$ProcessorMerger.process(ProcessorChain.java:190)
[TestEventLogger] at com.github.fge.jsonschema.core.processing.ProcessorChainTest.noFailureDoesNotTriggerEarlyExit(ProcessorChainTest.java:121)
[TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
The test setup needs a return value for p1
if process
is executed such as:
diff --git a/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java b/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java
index 072ad8b..d9764be 100644
--- a/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java
+++ b/src/test/java/com/github/fge/jsonschema/core/processing/ProcessorChainTest.java
@@ -114,11 +114,13 @@ public final class ProcessorChainTest
final MessageProvider input = mock(MessageProvider.class);
final ProcessingReport report = new DummyReport(LogLevel.DEBUG);
+
+ when(p1.process(report, input)).thenReturn(input);
processor.process(report, input);
- verify(p1).process(same(report), any(MessageProvider.class));
- verify(p2).process(same(report), any(MessageProvider.class));
+ verify(p1).process(same(report), isNotNull(MessageProvider.class));
+ verify(p2).process(same(report), isNotNull(MessageProvider.class));
}
private static final class DummyReport
With this setup the test case passed.