Created
August 19, 2016 23:42
-
-
Save tokuhirom/d214e8355aef077bf9479fafcc0e3a59 to your computer and use it in GitHub Desktop.
mockito
This file contains hidden or 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
package com.example; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.InjectMocks; | |
import org.mockito.runners.MockitoJUnitRunner; | |
import java.util.HashMap; | |
import java.util.Map; | |
import static org.mockito.Mockito.mock; | |
import static org.mockito.Mockito.verify; | |
public class HogeTest { | |
@Test | |
public void test() { | |
Hello hello = mock(Hello.class); | |
hello.greeting(new HashMap<String, Object>() {{ | |
put("hello", 3L); | |
}}); | |
verify(hello).greeting(new HashMap<String, Object>() {{ | |
put("hello", 3); | |
}}); | |
} | |
public static class Hello { | |
void greeting(Map<String, Object> l) { | |
} | |
} | |
} |
This file contains hidden or 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
Testing started at 8:37 AM ... | |
8:37:01 AM: Executing external tasks ':cleanTest :test --tests "com.example.HogeTest.test"'... | |
:cleanTest | |
:compileJava UP-TO-DATE | |
:processResources UP-TO-DATE | |
:classes UP-TO-DATE | |
:compileTestJava | |
:processTestResources UP-TO-DATE | |
:testClasses | |
:test | |
com.example.HogeTest > test FAILED | |
org.mockito.exceptions.verification.junit.ArgumentsAreDifferent at HogeTest.java:31 | |
Argument(s) are different! Wanted: | |
hello.greeting(() {hello=3}); | |
-> at com.example.HogeTest.test(HogeTest.java:31) | |
Actual invocation has different arguments: | |
hello.greeting(() {hello=3}); | |
-> at com.example.HogeTest.test(HogeTest.java:26) | |
Argument(s) are different! Wanted: | |
hello.greeting(() {hello=3}); | |
-> at com.example.HogeTest.test(HogeTest.java:31) | |
Actual invocation has different arguments: | |
hello.greeting(() {hello=3}); | |
-> at com.example.HogeTest.test(HogeTest.java:26) | |
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) | |
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) | |
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) | |
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) | |
at com.example.HogeTest.test(HogeTest.java:31) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:498) | |
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) | |
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) | |
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) | |
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) | |
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:309) | |
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37) | |
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62) | |
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:105) | |
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:56) | |
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64) | |
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:498) | |
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) | |
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) | |
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) | |
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) | |
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) | |
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:498) | |
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) | |
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) | |
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360) | |
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) | |
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) | |
at java.lang.Thread.run(Thread.java:745) | |
1 test completed, 1 failed | |
:test FAILED | |
FAILURE: Build failed with an exception. | |
* What went wrong: | |
Execution failed for task ':test'. | |
> There were failing tests. See the report at: file:///Users/tokuhirom/dev/mockito-sample/build/reports/tests/index.html | |
* Try: | |
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. | |
BUILD FAILED | |
Total time: 1.713 secs | |
There were failing tests. See the report at: file:///Users/tokuhirom/dev/mockito-sample/build/reports/tests/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment