{"id":13537127,"url":"https://github.com/varabyte/truthish","last_synced_at":"2025-10-12T21:41:57.043Z","repository":{"id":37883808,"uuid":"171226842","full_name":"varabyte/truthish","owner":"varabyte","description":"A Kotlin multiplatform unit testing library inspired by / similar to Google Truth.","archived":false,"fork":false,"pushed_at":"2025-02-07T22:40:04.000Z","size":511,"stargazers_count":117,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T04:34:38.261Z","etag":null,"topics":["hacktoberfest","kotlin","kotlin-android","kotlin-ios","kotlin-js","kotlin-jvm","kotlin-library","kotlin-linux","kotlin-macos","kotlin-mingw","kotlin-multiplatform","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varabyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"ko_fi":"bitspittle"}},"created_at":"2019-02-18T06:24:45.000Z","updated_at":"2025-03-15T08:21:04.000Z","dependencies_parsed_at":"2024-06-18T23:05:04.781Z","dependency_job_id":"b8066a41-ce78-4e78-8f1a-b905c07f0215","html_url":"https://github.com/varabyte/truthish","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varabyte%2Ftruthish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varabyte%2Ftruthish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varabyte%2Ftruthish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varabyte%2Ftruthish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varabyte","download_url":"https://codeload.github.com/varabyte/truthish/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990098,"owners_count":21995770,"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":["hacktoberfest","kotlin","kotlin-android","kotlin-ios","kotlin-js","kotlin-jvm","kotlin-library","kotlin-linux","kotlin-macos","kotlin-mingw","kotlin-multiplatform","unit-testing"],"created_at":"2024-08-01T09:00:55.366Z","updated_at":"2025-10-12T21:41:57.026Z","avatar_url":"https://github.com/varabyte.png","language":"Kotlin","funding_links":["https://ko-fi.com/bitspittle"],"categories":["Libraries"],"sub_categories":["Test"],"readme":"## Truthish\n\n![version](https://img.shields.io/badge/version-1.0.3-blue.svg)\n![truthish tests](https://github.com/varabyte/truthish/actions/workflows/gradle-test-all.yml/badge.svg)\n![coverage badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/bitspittle/01b6bfe88483946d9f5438f5616d9b9f/raw/truthish-coverage-badge.json)\n\u003cbr\u003e\n![kotlin version](https://img.shields.io/badge/kotlin_compatibility-1.6+-lightgray?logo=kotlin)\n![targets](https://img.shields.io/badge/targets-JVM,_JS,_Win,_Linux,_Mac,_Android,_iOS,_Wasm-white.svg)\n\u003cbr\u003e\n\u003ca href=\"https://discord.gg/bCdxPr7aTV\"\u003e\n  \u003cimg alt=\"Varabyte Discord\" src=\"https://img.shields.io/discord/886036660767305799.svg?label=\u0026logo=discord\u0026logoColor=ffffff\u0026color=7389D8\u0026labelColor=6A7EC2\" /\u003e\n\u003c/a\u003e\n[![Bluesky](https://img.shields.io/badge/Bluesky-0285FF?logo=bluesky\u0026logoColor=fff)](https://bsky.app/profile/bitspittle.bsky.social)\n\nA testing API inspired by [Google Truth](https://github.com/google/truth) but\nrewritten in Kotlin from the ground up, so it can be used in Kotlin\nmultiplatform projects.\n\nFor example, you can write `assertThat` checks in tests like this:\n\n```kotlin\nimport com.varabyte.truthish.*\n\nfun isEven(num: Int) = (num % 2) == 0\nfun square(num: Int) = (num * num)\n\n@Test\nfun testEvenOdd() {\n    assertThat(isEven(1234)).isTrue()\n    assertThat(isEven(1235)).isFalse()\n}\n\n@Test\nfun testSum() {\n    val nums = listOf(1, 2, 3, 4, 5)\n    assertThat(nums.sum()).isEqualTo(15)\n}\n\n@Test\nfun testMap() {\n    assertThat(listOf(1, 2, 3, 4, 5).map { square(it) })\n        .containsExactly(1, 4, 9, 16, 25)\n        .inOrder()\n}\n\n@Test\nfun customMessage() {\n    assertWithMessage(\"Unexpected list size\")\n        .that(listOf(1, 2, 3, 4, 5)).hasSize(5)\n}\n\n@Test\nfun testDivideByZeroException() {\n    val ex = assertThrows\u003cArithmeticException\u003e {\n        10 / 0\n    }\n    assertThat(ex.message).isEqualTo(\"/ by zero\")\n}\n```\n\nIf you would like to check multiple assertions at the same time (meaning a failure won't be reported until all checks\nhave run), you can use the `assertAll` function:\n\n```kotlin\nval person = Person(\"Alice\", 30)\nassertAll {\n    that(person.name).isEqualTo(\"Bob\")\n    that(person.age).isEqualTo(45)\n}\n// The above will assert once, reporting both equality check failures\n```\n\nYou can read the [Google Truth documentation](https://truth.dev/) for why they\nbelieve their fluent approach to assertions is both more readable and produces\ncleaner error messages, but let's break one of the tests above to see a\nspecific example error message:\n\n```kotlin\n@Test\nfun testMapButIntentionallyBroken() {\n    assertThat(listOf(1, 2, 3, 4, 5).map { square(it) })\n        .containsExactly(1, 4, 9, 15, 26) // \u003c-- Ooops, messed up 16 and 25 here\n        .inOrder()\n}\n```\n\nOutput:\n\n```text\nA collection did not contain element(s)\n\nExpected exactly all elements from: [ 1, 4, 9, 15, 26 ]\nBut was                           : [ 1, 4, 9, 16, 25 ]\nMissing                           : [ 15, 26 ]\nExtraneous                        : [ 16, 25 ]\n```\n\n# Using Truthish in Your Project\n\n## Multiplatform\n\nTo use *Truthish* in your multiplatform application, declare any of the following dependencies relevant to your project:\n\n```kotlin\n// build.gradle.kts\n// Multiplatform\n\nrepositories {\n    mavenCentral()\n}\n\nkotlin {\n    jvm()\n    js {\n        browser()\n        nodeJs()\n    }\n    wasmJs {\n      browser()\n      nodeJs()\n      d8()\n    }\n\n    linuxArm64()\n    linuxX64()\n    macosArm64() // Mac M1+\n    macosX64() // Mac Intel\n    mingwX64() // Windows\n    iosArm64() // iOS M1+\n    iosX64() // iOS Intel\n    iosSimulatorArm64()\n    androidTarget()\n\n    sourceSets {\n        commonTest.dependencies {\n            implementation(\"com.varabyte.truthish:truthish:1.0.3\")\n            implementation(kotlin(\"test\"))\n        }\n    }\n}\n```\n\n## Single platform\n\nYou can also use *Truthish* in non-multiplatform projects as well:\n\n### JVM\n\n```kotlin\n// build.gradle.kts\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    // ...\n\n    testImplementation(kotlin(\"test\"))\n    testImplementation(\"com.varabyte.truthish:truthish:1.0.3\")\n}\n```\n\n### Android\n\n```kotlin\n// build.gradle.kts\n\nrepositories {\n    mavenCentral()\n}\n\nandroid { /* ... */ }\n\ndependencies {\n    // ...\n\n    // If used in tests that are run on the host (i.e. your dev machine)\n    testImplementation(\"com.varabyte.truthish:truthish:1.0.3\")\n\n    // If used in tests that are run on the device\n    androidTestImplementation(\"com.varabyte.truthish:truthish:1.0.3\")\n}\n```\n\n### Testing snapshots\n\nMost users won't ever need to run a Truthish snapshot, so feel free to skip this section! However, occasionally, bug\nfixes and new features will be available for testing for a short period before they are released.\n\nIf you ever file a bug with Truthish and are asked to test a fix using a snapshot, you must add an entry for the sonatype\nsnapshots repository to your `repositories` block in order to allow Gradle to find it:\n\n```diff\n// build.gradle.kts\n\nrepositories {\n  mavenCentral()\n+ maven(\"https://central.sonatype.com/repository/maven-snapshots/\") {\n+   mavenContent {\n+     includeGroup(\"com.varabyte.truthish\")\n+     snapshotsOnly()\n+   }\n+ }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarabyte%2Ftruthish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarabyte%2Ftruthish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarabyte%2Ftruthish/lists"}