{"action":"created","comment":{"url":"https://api.github.com/repos/Netflix/governator/pulls/comments/83497751","pull_request_review_id":4341242,"id":83497751,"diff_hunk":"@@ -0,0 +1,81 @@\n+# Testing Governator With JUnit\n+To simplify integration testing of components wired together using Guice, you may use the [GovernatorJunit4ClassRunner](https://github.com/Netflix/governator/blob/master/governator-test-junit/src/main/java/com/netflix/governator/guice/test/junit4/GovernatorJunit4ClassRunner.java) JUnit runner. \n+\n+# Features\n+* Annotate your test with [@ModulesForTesting](https://github.com/Netflix/governator/blob/master/governator-test-junit/src/main/java/com/netflix/governator/guice/test/ModulesForTesting.java) to specify which Guice modules should be included when building your Injector.\n+* @Inject dependencies directly into your JUnit test class.\n+* Annotate dependencies with [@ReplaceWithMock](https://github.com/Netflix/governator/blob/master/governator-test-junit/src/main/java/com/netflix/governator/guice/test/ReplaceWithMock.java) to add an override binding for that dependency's type to a Mockito implementation. \n+* Annotate dependencies with [@WrapWithSpy](https://github.com/Netflix/governator/blob/master/governator-test-junit/src/main/java/com/netflix/governator/guice/test/WrapWithSpy.java) to wrap any binding with a Mockito spy.\n+* Annotate parent classes, test classes, and/or test methods with [@TestPropertyOverride](https://github.com/Netflix/archaius/blob/2.x/archaius2-test/src/main/java/com/netflix/archaius/test/TestPropertyOverride.java) to set [Archaius2](https://github.com/Netflix/archaius/tree/2.x) property overrides for your Injector **(Note: You must include [ArchaiusModule](https://github.com/Netflix/archaius/blob/2.x/archaius2-guice/src/main/java/com/netflix/archaius/guice/ArchaiusModule.java) yourself in @ModulesForTesting to use this feature.)**\n+\n+# Dependency\n+Add the following to your build.gradle\n+```\n+testCompile 'com.netflix.governator:governator-test-junit:latest.release'\n+```\n+\n+# Example\n+```java\n+@RunWith(GovernatorJunit4ClassRunner.class)                     //You must use the Runner for these features to work\n+@ModulesForTesting({ MyModule.class, ArchaiusModule.class })    //Specify any Modules you wish to include in your test\n+public class ExampleTest {\n+    \n+    @Inject\n+    @ReplaceWithMock                                            //Indicate that you wish this dependency to be Mocked\n+    SomeDependency dependency;  \n+    \n+    @Inject\n+    @WrapWithSpy                                                //Indicate that you wish to wrap this dependency with a Spy\n+    SomeRealDependency realDependency;                      \n+    \n+    @Before\n+    public void setup() {\n+        Mockito.when(dependency.getValue()).thenReturn(\"Test\"); //Specify desired behavior for your Mock\n+    }\n+    \n+    @Test\n+    public void testMock() {\n+        assertEquals(\"Test\", dependency.getValue());            //Verify behavior of your Mock\n+    }\n+    \n+    @Test\n+    public void testSpy() {\n+        realDependency.getValue();\n+        Mockito.verify(realDependency, Mockito.times(1)).getValue(); //Verify that this object was interacted with exactly once\n+    }\n+    \n+    @Inject\n+    Config config;\n+    \n+    @Test\n+    @TestPropertyOverride({\"myProperty=test\"})                    //Specify property values you wish to be set\n+    public void testConfig() {\n+        assertEquals(\"test\", config.getString(\"myProperty\"));    //Verify that your property was set as expected\n+    }\n+    \n+    @Test\n+    @TestPropertyOverride(propertyFiles={\"testProps.properties\"}) //Properties may also be loaded from a file\n+    public void testConfigFromFile() {\n+        assertEquals(\"test\", config.getString(\"myProperty\"));   //Verify that your property was set as expected\n+    }\n+}\n+```\n+\n+# Controlling Injector Creation\n+You may choose whether the Injector will be created once per test class or once per test method by setting the injectorCreation attribute of [@ModulesForTesting](https://github.com/Netflix/governator/blob/master/governator-test-junit/src/main/java/com/netflix/governator/guice/test/ModulesForTesting.java). **By default, the injector is created once per test class.** This should only be modified if your Injector is in some way stateful and that state has been modified by one of your tests.","path":"governator-test-junit/README.md","position":65,"original_position":65,"commit_id":"eb8f660851567df2265169669de99e286a55a217","original_commit_id":"eb8f660851567df2265169669de99e286a55a217","user":{"login":"noel-yap","id":1414385,"avatar_url":"https://avatars.githubusercontent.com/u/1414385?v=3","gravatar_id":"","url":"https://api.github.com/users/noel-yap","html_url":"https://github.com/noel-yap","followers_url":"https://api.github.com/users/noel-yap/followers","following_url":"https://api.github.com/users/noel-yap/following{/other_user}","gists_url":"https://api.github.com/users/noel-yap/gists{/gist_id}","starred_url":"https://api.github.com/users/noel-yap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noel-yap/subscriptions","organizations_url":"https://api.github.com/users/noel-yap/orgs","repos_url":"https://api.github.com/users/noel-yap/repos","events_url":"https://api.github.com/users/noel-yap/events{/privacy}","received_events_url":"https://api.github.com/users/noel-yap/received_events","type":"User","site_admin":false},"body":"What's actually important is whether or not the injected object is mutable. If the injected object is mutable, set the `injectorCreation` attribute of `@ModulesForTesting` to have a new instance of the `Injector` per test method.","created_at":"2016-10-14T20:43:16Z","updated_at":"2016-10-14T20:43:16Z","html_url":"https://github.com/Netflix/governator/pull/331#discussion_r83497751","pull_request_url":"https://api.github.com/repos/Netflix/governator/pulls/331","_links":{"self":{"href":"https://api.github.com/repos/Netflix/governator/pulls/comments/83497751"},"html":{"href":"https://github.com/Netflix/governator/pull/331#discussion_r83497751"},"pull_request":{"href":"https://api.github.com/repos/Netflix/governator/pulls/331"}}},"pull_request":{"url":"https://api.github.com/repos/Netflix/governator/pulls/331","id":89118815,"html_url":"https://github.com/Netflix/governator/pull/331","diff_url":"https://github.com/Netflix/governator/pull/331.diff","patch_url":"https://github.com/Netflix/governator/pull/331.patch","issue_url":"https://api.github.com/repos/Netflix/governator/issues/331","number":331,"state":"open","locked":false,"title":"Test runner enhancements ","user":{"login":"twicksell","id":301239,"avatar_url":"https://avatars.githubusercontent.com/u/301239?v=3","gravatar_id":"","url":"https://api.github.com/users/twicksell","html_url":"https://github.com/twicksell","followers_url":"https://api.github.com/users/twicksell/followers","following_url":"https://api.github.com/users/twicksell/following{/other_user}","gists_url":"https://api.github.com/users/twicksell/gists{/gist_id}","starred_url":"https://api.github.com/users/twicksell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twicksell/subscriptions","organizations_url":"https://api.github.com/users/twicksell/orgs","repos_url":"https://api.github.com/users/twicksell/repos","events_url":"https://api.github.com/users/twicksell/events{/privacy}","received_events_url":"https://api.github.com/users/twicksell/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-13T00:35:49Z","updated_at":"2016-10-14T20:43:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffc6d1676949eae46e0e42296a2a7e9d750b57c6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Netflix/governator/pulls/331/commits","review_comments_url":"https://api.github.com/repos/Netflix/governator/pulls/331/comments","review_comment_url":"https://api.github.com/repos/Netflix/governator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Netflix/governator/issues/331/comments","statuses_url":"https://api.github.com/repos/Netflix/governator/statuses/eb8f660851567df2265169669de99e286a55a217","head":{"label":"twicksell:testRunner","ref":"testRunner","sha":"eb8f660851567df2265169669de99e286a55a217","user":{"login":"twicksell","id":301239,"avatar_url":"https://avatars.githubusercontent.com/u/301239?v=3","gravatar_id":"","url":"https://api.github.com/users/twicksell","html_url":"https://github.com/twicksell","followers_url":"https://api.github.com/users/twicksell/followers","following_url":"https://api.github.com/users/twicksell/following{/other_user}","gists_url":"https://api.github.com/users/twicksell/gists{/gist_id}","starred_url":"https://api.github.com/users/twicksell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twicksell/subscriptions","organizations_url":"https://api.github.com/users/twicksell/orgs","repos_url":"https://api.github.com/users/twicksell/repos","events_url":"https://api.github.com/users/twicksell/events{/privacy}","received_events_url":"https://api.github.com/users/twicksell/received_events","type":"User","site_admin":false},"repo":{"id":50874441,"name":"governator","full_name":"twicksell/governator","owner":{"login":"twicksell","id":301239,"avatar_url":"https://avatars.githubusercontent.com/u/301239?v=3","gravatar_id":"","url":"https://api.github.com/users/twicksell","html_url":"https://github.com/twicksell","followers_url":"https://api.github.com/users/twicksell/followers","following_url":"https://api.github.com/users/twicksell/following{/other_user}","gists_url":"https://api.github.com/users/twicksell/gists{/gist_id}","starred_url":"https://api.github.com/users/twicksell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twicksell/subscriptions","organizations_url":"https://api.github.com/users/twicksell/orgs","repos_url":"https://api.github.com/users/twicksell/repos","events_url":"https://api.github.com/users/twicksell/events{/privacy}","received_events_url":"https://api.github.com/users/twicksell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/twicksell/governator","description":"Governator is a library of extensions and utilities that enhance Google Guice to provide: classpath scanning and automatic binding, lifecycle management, configuration to field mapping, field validation and parallelized object warmup.","fork":true,"url":"https://api.github.com/repos/twicksell/governator","forks_url":"https://api.github.com/repos/twicksell/governator/forks","keys_url":"https://api.github.com/repos/twicksell/governator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twicksell/governator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twicksell/governator/teams","hooks_url":"https://api.github.com/repos/twicksell/governator/hooks","issue_events_url":"https://api.github.com/repos/twicksell/governator/issues/events{/number}","events_url":"https://api.github.com/repos/twicksell/governator/events","assignees_url":"https://api.github.com/repos/twicksell/governator/assignees{/user}","branches_url":"https://api.github.com/repos/twicksell/governator/branches{/branch}","tags_url":"https://api.github.com/repos/twicksell/governator/tags","blobs_url":"https://api.github.com/repos/twicksell/governator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twicksell/governator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twicksell/governator/git/refs{/sha}","trees_url":"https://api.github.com/repos/twicksell/governator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twicksell/governator/statuses/{sha}","languages_url":"https://api.github.com/repos/twicksell/governator/languages","stargazers_url":"https://api.github.com/repos/twicksell/governator/stargazers","contributors_url":"https://api.github.com/repos/twicksell/governator/contributors","subscribers_url":"https://api.github.com/repos/twicksell/governator/subscribers","subscription_url":"https://api.github.com/repos/twicksell/governator/subscription","commits_url":"https://api.github.com/repos/twicksell/governator/commits{/sha}","git_commits_url":"https://api.github.com/repos/twicksell/governator/git/commits{/sha}","comments_url":"https://api.github.com/repos/twicksell/governator/comments{/number}","issue_comment_url":"https://api.github.com/repos/twicksell/governator/issues/comments{/number}","contents_url":"https://api.github.com/repos/twicksell/governator/contents/{+path}","compare_url":"https://api.github.com/repos/twicksell/governator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twicksell/governator/merges","archive_url":"https://api.github.com/repos/twicksell/governator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twicksell/governator/downloads","issues_url":"https://api.github.com/repos/twicksell/governator/issues{/number}","pulls_url":"https://api.github.com/repos/twicksell/governator/pulls{/number}","milestones_url":"https://api.github.com/repos/twicksell/governator/milestones{/number}","notifications_url":"https://api.github.com/repos/twicksell/governator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twicksell/governator/labels{/name}","releases_url":"https://api.github.com/repos/twicksell/governator/releases{/id}","deployments_url":"https://api.github.com/repos/twicksell/governator/deployments","created_at":"2016-02-01T21:58:39Z","updated_at":"2016-02-01T21:58:40Z","pushed_at":"2016-10-13T19:07:43Z","git_url":"git://github.com/twicksell/governator.git","ssh_url":"git@github.com:twicksell/governator.git","clone_url":"https://github.com/twicksell/governator.git","svn_url":"https://github.com/twicksell/governator","homepage":"","size":3077,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Netflix:master","ref":"master","sha":"538db9d621d3c123bc19d4f0366ebe734d7d9929","user":{"login":"Netflix","id":913567,"avatar_url":"https://avatars.githubusercontent.com/u/913567?v=3","gravatar_id":"","url":"https://api.github.com/users/Netflix","html_url":"https://github.com/Netflix","followers_url":"https://api.github.com/users/Netflix/followers","following_url":"https://api.github.com/users/Netflix/following{/other_user}","gists_url":"https://api.github.com/users/Netflix/gists{/gist_id}","starred_url":"https://api.github.com/users/Netflix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netflix/subscriptions","organizations_url":"https://api.github.com/users/Netflix/orgs","repos_url":"https://api.github.com/users/Netflix/repos","events_url":"https://api.github.com/users/Netflix/events{/privacy}","received_events_url":"https://api.github.com/users/Netflix/received_events","type":"Organization","site_admin":false},"repo":{"id":4941867,"name":"governator","full_name":"Netflix/governator","owner":{"login":"Netflix","id":913567,"avatar_url":"https://avatars.githubusercontent.com/u/913567?v=3","gravatar_id":"","url":"https://api.github.com/users/Netflix","html_url":"https://github.com/Netflix","followers_url":"https://api.github.com/users/Netflix/followers","following_url":"https://api.github.com/users/Netflix/following{/other_user}","gists_url":"https://api.github.com/users/Netflix/gists{/gist_id}","starred_url":"https://api.github.com/users/Netflix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netflix/subscriptions","organizations_url":"https://api.github.com/users/Netflix/orgs","repos_url":"https://api.github.com/users/Netflix/repos","events_url":"https://api.github.com/users/Netflix/events{/privacy}","received_events_url":"https://api.github.com/users/Netflix/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Netflix/governator","description":"Governator is a library of extensions and utilities that enhance Google Guice to provide: classpath scanning and automatic binding, lifecycle management, configuration to field mapping, field validation and parallelized object warmup.","fork":false,"url":"https://api.github.com/repos/Netflix/governator","forks_url":"https://api.github.com/repos/Netflix/governator/forks","keys_url":"https://api.github.com/repos/Netflix/governator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Netflix/governator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Netflix/governator/teams","hooks_url":"https://api.github.com/repos/Netflix/governator/hooks","issue_events_url":"https://api.github.com/repos/Netflix/governator/issues/events{/number}","events_url":"https://api.github.com/repos/Netflix/governator/events","assignees_url":"https://api.github.com/repos/Netflix/governator/assignees{/user}","branches_url":"https://api.github.com/repos/Netflix/governator/branches{/branch}","tags_url":"https://api.github.com/repos/Netflix/governator/tags","blobs_url":"https://api.github.com/repos/Netflix/governator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Netflix/governator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Netflix/governator/git/refs{/sha}","trees_url":"https://api.github.com/repos/Netflix/governator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Netflix/governator/statuses/{sha}","languages_url":"https://api.github.com/repos/Netflix/governator/languages","stargazers_url":"https://api.github.com/repos/Netflix/governator/stargazers","contributors_url":"https://api.github.com/repos/Netflix/governator/contributors","subscribers_url":"https://api.github.com/repos/Netflix/governator/subscribers","subscription_url":"https://api.github.com/repos/Netflix/governator/subscription","commits_url":"https://api.github.com/repos/Netflix/governator/commits{/sha}","git_commits_url":"https://api.github.com/repos/Netflix/governator/git/commits{/sha}","comments_url":"https://api.github.com/repos/Netflix/governator/comments{/number}","issue_comment_url":"https://api.github.com/repos/Netflix/governator/issues/comments{/number}","contents_url":"https://api.github.com/repos/Netflix/governator/contents/{+path}","compare_url":"https://api.github.com/repos/Netflix/governator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Netflix/governator/merges","archive_url":"https://api.github.com/repos/Netflix/governator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Netflix/governator/downloads","issues_url":"https://api.github.com/repos/Netflix/governator/issues{/number}","pulls_url":"https://api.github.com/repos/Netflix/governator/pulls{/number}","milestones_url":"https://api.github.com/repos/Netflix/governator/milestones{/number}","notifications_url":"https://api.github.com/repos/Netflix/governator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Netflix/governator/labels{/name}","releases_url":"https://api.github.com/repos/Netflix/governator/releases{/id}","deployments_url":"https://api.github.com/repos/Netflix/governator/deployments","created_at":"2012-07-07T22:28:42Z","updated_at":"2016-10-12T06:52:12Z","pushed_at":"2016-10-13T19:07:43Z","git_url":"git://github.com/Netflix/governator.git","ssh_url":"git@github.com:Netflix/governator.git","clone_url":"https://github.com/Netflix/governator.git","svn_url":"https://github.com/Netflix/governator","homepage":"","size":4900,"stargazers_count":438,"watchers_count":438,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":119,"mirror_url":null,"open_issues_count":43,"forks":119,"open_issues":43,"watchers":438,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Netflix/governator/pulls/331"},"html":{"href":"https://github.com/Netflix/governator/pull/331"},"issue":{"href":"https://api.github.com/repos/Netflix/governator/issues/331"},"comments":{"href":"https://api.github.com/repos/Netflix/governator/issues/331/comments"},"review_comments":{"href":"https://api.github.com/repos/Netflix/governator/pulls/331/comments"},"review_comment":{"href":"https://api.github.com/repos/Netflix/governator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Netflix/governator/pulls/331/commits"},"statuses":{"href":"https://api.github.com/repos/Netflix/governator/statuses/eb8f660851567df2265169669de99e286a55a217"}}}}
{"actor":{"display_login":"noel-yap"}}