{"id":17101313,"url":"https://github.com/behindthemath/testwithlogstub","last_synced_at":"2025-03-23T19:16:09.867Z","repository":{"id":221086632,"uuid":"82641100","full_name":"BehindTheMath/TestWithLogStub","owner":"BehindTheMath","description":"Class that stubs out android.util.Log for unit testing","archived":false,"fork":false,"pushed_at":"2017-02-21T06:02:13.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-15T15:24:41.742Z","etag":null,"topics":["android","junit","junit4","mockito","powermock"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BehindTheMath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-21T05:45:37.000Z","updated_at":"2017-02-21T05:58:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"72068c1a-5521-442a-80b2-2832aa80c12e","html_url":"https://github.com/BehindTheMath/TestWithLogStub","commit_stats":null,"previous_names":["behindthemath/testwithlogstub"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BehindTheMath%2FTestWithLogStub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BehindTheMath%2FTestWithLogStub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BehindTheMath%2FTestWithLogStub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BehindTheMath%2FTestWithLogStub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BehindTheMath","download_url":"https://codeload.github.com/BehindTheMath/TestWithLogStub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245153896,"owners_count":20569408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","junit","junit4","mockito","powermock"],"created_at":"2024-10-14T15:24:44.740Z","updated_at":"2025-03-23T19:16:09.829Z","avatar_url":"https://github.com/BehindTheMath.png","language":"Java","readme":"# Test With Log Stub\nThis is a class that stubs out `android.util.Log` for unit testing, using [PowerMock](\u003chttps://github.com/powermock/powermock\u003e) and [Mockito](\u003chttp://site.mockito.org/\u003e). All `Log.*` methods are redirected to `System.out.println()`, so the output shows in the JUnit console. This allows easy unit testing of code with calls to `Log.*`, without requiring extensive modification to implement dependency injection, while still showing the output in the console.\n\n## Usage\n1. Copy `TestWithLogStub.java` to your project, and rename the package name to match your package.\n2. Make sure you have the following lines in the `dependencies` block in your module-level `build.gradle`:\n```java\n    testCompile 'junit:junit:4.12'\n    testCompile 'org.mockito:mockito-core:1.10.19'\n    testCompile 'org.powermock:powermock-api-mockito:1.6.6'\n    testCompile 'org.powermock:powermock-module-junit4:1.6.6'\n```\n3. Subclass the TestWithLogStub class, and add your own methods. Call `Log.*` as usual, and the output will be redirected to the console.\n\n**Example:**\n```java\npackage io.behindthemath.test;\n\nimport android.util.Log;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertEquals;\n\npublic class TestClass extends TestWithLogStub {\n    @Test\n    public void test() {\n        Log.i(\"TestClass\", \"This is a test\");\n\n        assertEquals(true, true);\n    }\n}\n\n```\n**Output:**\n`I/TestClass: This is a test`\n\n## License\nCopyright 2017 Behind The Math\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbehindthemath%2Ftestwithlogstub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbehindthemath%2Ftestwithlogstub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbehindthemath%2Ftestwithlogstub/lists"}