{"id":22043137,"url":"https://github.com/eranboudjnah/testit","last_synced_at":"2025-05-08T01:23:07.201Z","repository":{"id":64952043,"uuid":"195549129","full_name":"EranBoudjnah/TestIt","owner":"EranBoudjnah","description":"Generate unit testing boilerplate from kotlin files.","archived":false,"fork":false,"pushed_at":"2025-05-06T20:10:58.000Z","size":32560,"stargazers_count":44,"open_issues_count":5,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-06T21:25:03.624Z","etag":null,"topics":["generator","junit","junit4","kotlin","mockito","mockito-kotlin","mockk","unit-test","unit-testing","unit-tests","unittest"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EranBoudjnah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2019-07-06T14:34:47.000Z","updated_at":"2025-04-13T14:58:13.000Z","dependencies_parsed_at":"2024-01-10T16:58:16.615Z","dependency_job_id":"8bc94a04-d68e-4d0d-b8c2-ff1d9ff0d33c","html_url":"https://github.com/EranBoudjnah/TestIt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EranBoudjnah%2FTestIt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EranBoudjnah%2FTestIt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EranBoudjnah%2FTestIt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EranBoudjnah%2FTestIt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EranBoudjnah","download_url":"https://codeload.github.com/EranBoudjnah/TestIt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252979621,"owners_count":21835091,"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":["generator","junit","junit4","kotlin","mockito","mockito-kotlin","mockk","unit-test","unit-testing","unit-tests","unittest"],"created_at":"2024-11-30T12:15:11.129Z","updated_at":"2025-05-08T01:23:07.169Z","avatar_url":"https://github.com/EranBoudjnah.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestIt\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/EranBoudjnah/TestIt/test.yml)\n[![License](https://img.shields.io/github/license/EranBoudjnah/Solid)](https://github.com/EranBoudjnah/TestIt/blob/master/LICENSE)\n\nWhile [TDD](https://en.wikipedia.org/wiki/Test-driven_development) is a better approach for development, many projects don't practice it and end up with low test coverage.\n\nThis project is here to help you improve your test coverage by reducing the effort spent on writing boilerplate code, allowing you to focus on writing the actual tests.\n\nUse TestIt to generate unit testing boilerplate from kotlin files.\n\n## Getting Started\n\nWhile you can run `./gradlew run --args \"filepath\"`, it might be more convenient to set up a shortcut to the provided helper script:\n\n### Install\n\n1. Get [HomeBrew](https://brew.sh/)\n2. Run `brew install coreutils`\n3. Create a symbolic link: `sudo ln -s /path/to/testit /usr/local/bin`\n\nNote: your project would need to include [mockito 2](https://site.mockito.org/) and [mockito-kotlin](https://github.com/nhaarman/mockito-kotlin) or [MockK](https://mockk.io/).\n\n## Usage\n\nOnce installed, running TestIt is as simple as\n\n`testit path/to/file.kt`\n\nOr, to generate parameterized tests:\n\n`testit -p path/to/file.kt`\n\n## Output\n\nTestIt generates a test file in the default expected path.\n\nFor example, when run against itself (`testit app/src/main/java/com/mitteloupe/testit/TestIt.kt`) -\nsee [source file](https://github.com/EranBoudjnah/TestIt/blob/master/app/src/main/java/com/mitteloupe/testit/TestIt.kt) -\nit generates the below file at `app/src/test/java/com/mitteloupe/testit/TestItTest.kt`:\n\n```kotlin\npackage com.mitteloupe.testit\n\nimport com.mitteloupe.testit.config.PropertiesReader\nimport com.mitteloupe.testit.file.FileProvider\nimport com.mitteloupe.testit.generator.TestFilePathFormatter\nimport com.mitteloupe.testit.generator.TestsGeneratorFactory\nimport com.mitteloupe.testit.model.ClassTestCode\nimport com.mitteloupe.testit.parser.KotlinFileParser\nimport org.mockito.kotlin.mock\nimport org.junit.Before\nimport org.junit.Test\nimport org.junit.runner.RunWith\nimport org.mockito.Mock\nimport org.mockito.junit.MockitoJUnitRunner\n\n@RunWith(MockitoJUnitRunner::class)\nclass TestItTest {\n    private lateinit var cut: TestIt\n\n    @Mock\n    lateinit var propertiesReader: PropertiesReader\n\n    @Mock\n    lateinit var fileProvider: FileProvider\n\n    @Mock\n    lateinit var kotlinFileParser: KotlinFileParser\n\n    @Mock\n    lateinit var testFilePathFormatter: TestFilePathFormatter\n\n    @Mock\n    lateinit var testsGeneratorFactory: TestsGeneratorFactory\n\n    @Before\n    fun setUp() {\n        cut = TestIt(propertiesReader, fileProvider, kotlinFileParser, testFilePathFormatter, testsGeneratorFactory)\n    }\n\n    @Test\n    fun `Given _ when getTestsForFile then _`() {\n        // Given\n        val fileName = \"fileName\"\n\n        // When\n        val actualValue = cut.getTestsForFile(fileName)\n\n        // Then\n        TODO(\"Define assertions\")\n    }\n\n    @Test\n    fun `Given _ when saveTestsToFile then _`() {\n        // Given\n        val sourceFileName = \"sourceFileName\"\n        val classTestCode = mock\u003cClassTestCode\u003e()\n\n        // When\n        cut.saveTestsToFile(sourceFileName, classTestCode)\n\n        // Then\n        TODO(\"Define assertions\")\n    }\n\n    @Test\n    fun `Given _ when showHelp then _`() {\n        // Given\n\n        // When\n        cut.showHelp()\n\n        // Then\n        TODO(\"Define assertions\")\n    }\n}\n```\n\n## Features\n\n* Automatically compiles a list of required imports\n* Supports multiple classes in one Kotlin file\n* Supports overloaded functions\n* Supports both [mockito 2](https://site.mockito.org/) and [MockK](https://mockk.io/)\n* Generates test code for abstract classes\n* Generates test code for extension functions\n* Generates test code for static functions\n* Generates parameterized tests code\n* Generates test code for exceptions\n* Configurable\n\n## Acknowledgments\n\nThis code uses a JAR from [kotlin-grammar-tools](https://github.com/Kotlin/grammar-tools) to parse Kotlin code.\n\n## Created by\n[Eran Boudjnah](https://www.linkedin.com/in/eranboudjnah)\n\n## License\nMIT © [Eran Boudjnah](https://www.linkedin.com/in/eranboudjnah)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feranboudjnah%2Ftestit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feranboudjnah%2Ftestit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feranboudjnah%2Ftestit/lists"}