{"id":26078310,"url":"https://github.com/danielepantaleone/kttestexpectation","last_synced_at":"2026-04-22T06:01:52.733Z","repository":{"id":204720632,"uuid":"712332637","full_name":"danielepantaleone/KTTestExpectation","owner":"danielepantaleone","description":"A simple Kotlin implementation of Swift's expectation","archived":false,"fork":false,"pushed_at":"2024-02-07T11:37:22.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T03:57:41.661Z","etag":null,"topics":["asynchronous-programming","expectation","junit","kotlin","swift","unit-testing"],"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/danielepantaleone.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}},"created_at":"2023-10-31T09:03:41.000Z","updated_at":"2023-11-29T20:15:55.000Z","dependencies_parsed_at":"2024-02-07T12:43:18.227Z","dependency_job_id":"3d4501a8-6fdb-4c6e-96db-23f303b5b8e2","html_url":"https://github.com/danielepantaleone/KTTestExpectation","commit_stats":null,"previous_names":["danielepantaleone/kttestexpectation"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/danielepantaleone/KTTestExpectation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FKTTestExpectation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FKTTestExpectation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FKTTestExpectation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FKTTestExpectation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielepantaleone","download_url":"https://codeload.github.com/danielepantaleone/KTTestExpectation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FKTTestExpectation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32123604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asynchronous-programming","expectation","junit","kotlin","swift","unit-testing"],"created_at":"2025-03-09T03:57:45.122Z","updated_at":"2026-04-22T06:01:52.704Z","avatar_url":"https://github.com/danielepantaleone.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KTTestExpectation\n\n[![API](https://img.shields.io/badge/API-23%2B-green.svg)](https://android-arsenal.com/api?level=23)\n![GitHub](https://img.shields.io/github/license/danielepantaleone/KTTestExpectation)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/danielepantaleone/KTTestExpectation)\n[![Android Tests](https://github.com/danielepantaleone/KTTestExpectation/actions/workflows/android-tests.yml/badge.svg)](https://github.com/danielepantaleone/KTTestExpectation/actions/workflows/android-tests.yml)\n\nThe purpose of this library is to provide simple Kotlin implementation of Swift's expectation to ease testing of asynchronous code that doesn't make use of Kotlin coroutines.\n\n## Table of contents\n\n* [Installation](#installation)\n* [Basic usage](#basic-usage)\n* [Advanced usage](#advanced-usage)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Installation\n\nAdd the MavenCentral repository to your `build.gradle` (Gradle Groovy) or `build.gradle.kts` (Kotlin DSL):\n\n```gradle\nrepositories {\n    mavenCentral()\n}\n```\n\nAdd the dependency to your `build.gradle` (Gradle Groovy):\n\n```gradle\ndependencies {\n    androidTestImplementation 'io.github.danielepantaleone:kttestexpectation:1.2.1'\n}\n```\n\nor `build.gradle.kts` (Kotlin DSL):\n\n```gradle\ndependencies {\n    androidTestImplementation(\"io.github.danielepantaleone:kttestexpectation:1.2.1\")\n}\n```\n\n## Basic usage\n\nAwaiting on a single expectation:\n\n```kotlin\n@Test\nfun testAwaitSingleExpectation() {\n    val expectation = expectation(\"Expectation\")\n    asyncLongOperationWithCallback {\n        expectation.fulfill()\n    }\n    waitForExpectation(\n        expectation = expectation,\n        time = 10,\n        unit = TimeUnit.SECONDS\n    )\n}\n```\n\nAwaiting on multiple expectations:\n\n```kotlin\n@Test\nfun testAwaitMultipleExpectations() {\n    val expectation1 = expectation(\"Expectation 1\")\n    val expectation2 = expectation(\"Expectation 2\")\n    asyncLongOperationWithCallback {\n        expectation1.fulfill()\n    }\n    asyncLongerOperationWithCallback {\n        expectation2.fulfill()\n    }\n    waitForExpectations(\n        expectations = listOf(expectation1, expectation2),\n        time = 20,\n        unit = TimeUnit.SECONDS\n    )\n}\n```\n\n## Advanced usage\n\nAwaiting on multiple expectations with different expected fulfillment count:\n\n```kotlin\n@Test\nfun testAwaitMultipleExpectations() {\n    val expectation1 = expectation(\"Expectation 1\")\n    val expectation2 = expectation(\"Expectation 2\")\n    expectation2.expectedFulfillmentCount = 2\n    asyncLongOperationWithCallback {\n        expectation1.fulfill()\n    }\n    asyncLongerOperationWithCallback {\n        expectation2.fulfill()\n        asyncLongestLongerOperationWithCallback {\n            expectation2.fulfill()\n        }   \n    }\n    waitForExpectations(\n        expectations = listOf(expectation1, expectation2),\n        time = 60,\n        unit = TimeUnit.SECONDS\n    )\n}\n```\n\nAwaiting on multiple expectations of different types:\n\n```kotlin\n@Test\nfun testAwaitMultipleExpectationsWithMixedTypes() {\n    val expectation1 = expectation(\"Expectation 1\")\n    val expectation2 = expectation(\"Expectation 2\") {  // no need to manually fulfill()\n        somePredicateThatWillEventuallyEvaluateToTrue()\n    }\n    asyncLongOperationWithCallback {\n        expectation1.fulfill()\n    }\n    waitForExpectations(\n        expectations = listOf(expectation1, expectation2),\n        time = 60,\n        unit = TimeUnit.SECONDS\n    )\n}\n```\n\n## Contributing\n\nIf you like this project you can contribute it by:\n\n- Submit a bug report by opening an [issue](https://github.com/danielepantaleone/KTTestExpectation/issues)\n- Submit code by opening a [pull request](https://github.com/danielepantaleone/KTTestExpectation/pulls)\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2023 Daniele Pantaleone\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielepantaleone%2Fkttestexpectation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielepantaleone%2Fkttestexpectation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielepantaleone%2Fkttestexpectation/lists"}