{"id":15130318,"url":"https://github.com/agoda-com/kakao","last_synced_at":"2025-09-28T19:32:00.745Z","repository":{"id":51051972,"uuid":"104835572","full_name":"agoda-com/Kakao","owner":"agoda-com","description":"This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao","archived":true,"fork":false,"pushed_at":"2021-05-26T07:38:45.000Z","size":1318,"stargazers_count":1111,"open_issues_count":0,"forks_count":102,"subscribers_count":53,"default_branch":"master","last_synced_at":"2024-12-22T01:40:29.461Z","etag":null,"topics":["android","android-test","android-ui","dsl","espresso","kotlin","testing-framework","testing-library","testing-tool","ui-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/agoda-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2017-09-26T04:21:50.000Z","updated_at":"2024-10-20T06:21:27.000Z","dependencies_parsed_at":"2022-09-13T08:41:22.220Z","dependency_job_id":null,"html_url":"https://github.com/agoda-com/Kakao","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agoda-com%2FKakao","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agoda-com%2FKakao/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agoda-com%2FKakao/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agoda-com%2FKakao/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agoda-com","download_url":"https://codeload.github.com/agoda-com/Kakao/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234555885,"owners_count":18851864,"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","android-test","android-ui","dsl","espresso","kotlin","testing-framework","testing-library","testing-tool","ui-testing"],"created_at":"2024-09-26T02:45:07.114Z","updated_at":"2025-09-28T19:32:00.071Z","avatar_url":"https://github.com/agoda-com.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kakao project is now being developed here: [KakaoCup/Kakao](https://github.com/KakaoCup/Kakao).\n### Kudos to all contributors and maintainers!\n\n### This repo is no longer supported.\n### Archived versions are available in maven central, for new releases please follow a new repo.\n\n# Kakao\n[ ![Download](https://api.bintray.com/packages/agoda/maven/kakao/images/download.svg) ](https://bintray.com/agoda/maven/kakao/_latestVersion)\n[![CircleCI](https://circleci.com/gh/agoda-com/Kakao/tree/master.svg?style=shield\u0026circle-token=0d0ed659625be4efe54fe706c16894cd54213690)](https://circleci.com/gh/agoda-com/Kakao/tree/master)\n[![Kotlin version badge](https://img.shields.io/badge/kotlin-1.4.10-blue.svg)](http://kotlinlang.org/)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Kakao-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6314)\n\nNice and simple DSL for Espresso in Kotlin\n\n### Introduction\nAt Agoda, we have more than 1000 automated tests to ensure our application's quality and give our best experience to the user. All of them are written with Espresso from Google. Even though Espresso is working really well with our test, the code readability is quite low. Let's look at some of the examples of how we write the test. \n```Java\nonView(allOf(withId(R.id.price_item), hasDescendant(withText(\"Standard Rate\"))))\n        .check(matches(withEffectiveVisibility(Visibility.VISIBLE)));\n```\nThis is an example just to check the visibility and you can see that it's not looking that good. As Agoda developers, we want to improve not just our codebase quality, but also our implementation of tests as well. This is why we are introducing Kakao. The library that will make you enjoy writing automated tests like you are drinking a hot chocolate.\n\n![coco](https://user-images.githubusercontent.com/2812510/30947310-3825724c-a433-11e7-8a0d-3c3bfe00d584.png)\n\n#### Benefits\n- Readability\n- Reusability\n- Extensible DSL\n\n### How to use it\n#### Create Screen\nCreate your entity `Screen` where you will add the views involved in the interactions of the tests:\n```Kotlin\nclass FormScreen : Screen\u003cFormScreen\u003e()\n```\n `Screen` can represent the whole user interface or a portion of UI.\nIf you are using [Page Object pattern](https://martinfowler.com/bliki/PageObject.html) you can put the interactions of Kakao inside the Page Objects.\n\n#### Create KView\n`Screen` contains `KView`, these are the Android Framework views where you want to do the interactions:\n```Kotlin\nclass FormScreen : Screen\u003cFormScreen\u003e() {\n    val phone = KEditText { withId(R.id.phone) }\n    val email = KEditText { withId(R.id.email) }\n    val submit = KButton { withId(R.id.submit) }\n}\n```\nKakao provides different types depending on the type of view:\n* `KView`\n* `KEditText`\n* `KTextView`\n* `KButton`\n* `KImageView`\n* `KWebView`\n* `KCheckbox`\n* `KViewPager`\n* `KSeekBar`\n* `KSwitch`\n* \u003cb\u003eand more\u003c/b\u003e\n\n\nEvery `KView` contains matchers to retrieve the view involved in the `ViewInteraction`. Some examples of matchers provided\nby Kakao:\n\n* `withId`\n* `withText`\n* `withContentDescription`\n* `withDrawable`\n* `withBackgroundColor`\n* \u003cb\u003eand more\u003c/b\u003e\n\nLike in Espresso you can combine different matchers:\n```Kotlin\nval email = KEditText { \n    withId(R.id.email)\n    withText(R.string.email)\n}\n```\n\nAnd you can use your custom matchers:\n\n```Kotlin\nval email = KEditText { \n    withId(R.id.email)\n    matches { MyCustomMatcher.matches(position) }\n}\n```\n\n#### Write the interaction. \n\nThe syntax of the test with Kakao is very easy, once you have the `Screen` and the `KView` defined, you only have to apply \nthe actions or assertions like in Espresso: \n```Kotlin\nonScreen\u003cFormScreen\u003e {\n    phone {\n       hasText(\"971201771\")\n    }\n    button {\n       click()\n    }\n}\n```\nKakao provides multiple actions/assertions based on Espresso. Furthermore, you can combine them, just like the matchers. \nYou can use your custom assertions or your custom actions too:\n```Kotlin\nonScreen\u003cFormScreen\u003e {\n    phone {\n       assert { MyCustomAssertion.isThaiNumber() }\n    }\n    button {\n       act { MyCustomAction.clickOnTheCorner() }\n    }\n}\n```\n\n#### Advanced \n\n##### ListView/RecyclersView\n\nKakao offers an easy way to interact with your `RecyclerView` and `ListView`\n\n###### Create the KListView/KRecyclerView \nInside your `Screen` create the KView matching with your view:\n\nFor `KListView`:\n```Kotlin\nval list = KListView { builder = { withId(R.id.list) } }\n```\nFor `KRecyclerView`:\n```Kotlin\nval recycler = KRecyclerView { builder = { withId(R.id.recycler_view) } }\n```\n\nYou can combine different matchers to retrieve your view.\n\n###### Create KAdapterItem/KRecyclerItem \n\nEvery adapter contains different Items, Kakao provides an easy way to define the different items of your adapter \nwith `KAdapterItem` and `KRecyclerItem`.\nIf your adapter contains multiple Items but your interactions in your tests only work with \none is not required to create all of them. \n\n`KAdapterItem`\n```Kotlin\nclass Item(i: DataInteraction) : KAdapterItem\u003cItem\u003e(i) {\n    val title = KTextView(i) { withId(R.id.title) }\n    val subtitle = KTextView(i) { withId(R.id.subtitle) }\n    val button = KButton(i) { withId(R.id.button) }\n}\n```\n    \n`KRecyclerItem`    \n```Kotlin\nclass Item(parent: Matcher\u003cView\u003e) : KRecyclerItem\u003cItem\u003e(parent) {\n    val title: KTextView = KTextView(parent) { withId(R.id.title) }\n    val subtitle: KTextView = KTextView(parent) { withId(R.id.subtitle) }\n}\n```\n\nThe `KView` defined in the Item corresponds views used on the Item. You can assign the `KItems` to the\n `KListView`/ `KRecyclerView` like:\n\n```Kotlin\nval recycler: KRecyclerView = KRecyclerView({\n    withId(R.id.recycler_view)\n}, itemTypeBuilder = {\n    itemType(::Item)\n})\n```\n\nAnd finally your final interaction will be:\n```Kotlin\nonScreen\u003cRecyclerScreen\u003e {\n    recycler {\n        firstChild\u003cTestRecyclerScreen.Item\u003e {\n            isVisible()\n            title { hasText(\"Title 1\") }\n        }\n    }\n}\n```\nKakao provides different accessors in the adapter:\n* `childAt`\n* `firstChild`\n* `lastChild`\n* `childWith`\n\n##### Custom KView\n\nIf you have custom Views in your tests and you want to create your own `KView`, we have `KBaseView`. Just extend \nthis class and implement as much additional Action/Assertion interfaces as you want. \nYou also need to override constructors that you need.\n\n```Kotlin\nclass KMyView : KBaseView\u003cKView\u003e, MyActions, MyAssertions {\n    constructor(function: ViewBuilder.() -\u003e Unit) : super(function)\n    constructor(parent: Matcher\u003cView\u003e, function: ViewBuilder.() -\u003e Unit) : super(parent, function)\n    constructor(parent: DataInteraction, function: ViewBuilder.() -\u003e Unit) : super(parent, function)\n}\n```\n\n##### Intercepting\n\nIf you need to add custom logic during the `Kakao -\u003e Espresso` call chain (for example, logging) or\nif you need to completely change the `ViewAssertion` or `ViewAction` that are being sent to Espresso\nduring runtime in some cases, you can use the intercepting mechanism.\n\nInterceptors are lambdas that you pass to a configuration DSL that will be invoked before `ViewInteraction`,\n`DataInteraction` or `Web.WebInteraction` classes' `perform` and `check` calls happening from inside Kakao.\n\nYou have the ability to provide interceptors at 3 different levels: Kakao runtime, your 'Screen' classes\nand any individual `KView` instance.\n\nOn each invocation of Espresso function that can be intercepted, Kakao will aggregate all available interceptors\nfor this particular call and invoke them in descending order: `KView interceptor -\u003e Active Screens interceptors -\u003e\nKakao interceptor`.\n\nEach of the interceptors in the chain can break the chain call by setting `isOverride` to true during configuration.\nIn that case Kakao will not only stop invoking remaining interceptors in the chain, **but will not perform the Espresso\ncall**. It means that in such case, the responsibility to actually invoke Espresso lies on the shoulders\nof the developer.\n\nHere's the examples of intercepting configurations:\n```Kotlin\nclass SomeTest {\n    @Before\n    fun setup() {\n        Kakao { // Kakao runtime\n            intercept {\n                onViewInteraction { // Intercepting calls on ViewInteraction classes across whole runtime\n                    onPerform { interaction, action -\u003e // Intercept perform() call\n                        Log.d(\"KAKAO\", \"$interaction is performing $action\")\n                    }\n                }\n            }\n        }\n    }\n    \n    @Test\n    fun test() {\n        onScreen\u003cMyScreen\u003e {\n            intercept {\n                onViewInteraction { // Intercepting calls on ViewInteraction classes while in the context of MyScreen\n                    onCheck { interaction, assertion -\u003e // Intercept check() call\n                        Log.d(\"KAKAO\", \"$interaction is checking $assertion\")\n                    }\n                }\n            }\n            \n            myView {\n                intercept { // Intercepting ViewInteraction calls on this individual view\n                    onPerform(true) { interaction, action -\u003e // Intercept perform() call and overriding the chain \n                        // When performing actions on this view, Kakao level interceptor will not be called\n                        // and we have to manually call Espresso now.\n                        Log.d(\"KAKAO_VIEW\", \"$interaction is performing $action\")\n                        interaction.perform(action)\n                    }\n                }\n            }\n        }\n    }\n}\n```\nFor more detailed info please refer to the documentation.\n\n### Setup\nFollowing archived versions are available in maven central:\n- 2.4.0\n- 2.3.4\n- 2.2.0\n- 2.1.0\n- 2.1.0-support\n- 1.4.0-androidx\n\nMaven\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.agoda.kakao\u003c/groupId\u003e\n  \u003cartifactId\u003ekakao\u003c/artifactId\u003e\n  \u003cversion\u003e\u003clatest version\u003e\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\nor Gradle:\n```groovy\nrepositories {\n    jcenter()\n}\n\ndependencies {\n    androidTestImplementation 'com.agoda.kakao:kakao:\u003clatest version\u003e'\n}\n```\n\n### AndroidX\nDefault artifact starting from `2.0.0` includes AndroidX libraries to build upon. If you're still using\nold support libraries, please use `2.X.X-support` artifact.\n```\ndependencies {\n    androidTestImplementation 'com.agoda.kakao:kakao:2.1.0-support'\n}\n```\n**IMPORTANT:** We stopped the development for the `-support` artifact and version `2.1.0-support` is the\nlatest version available with usage of support libraries. Please consider migrating to AndroidX.\n\n### Contribution Policy\n\n**Kakao** is an open source project, and depends on its users to improve it. We are more than happy to find you interested in taking the project forward.\n\nKindly refer to the [Contribution Guidelines](https://github.com/agoda-com/kakao/blob/master/CONTRIBUTING.md) for detailed information.\n\n### Code of Conduct\n\nPlease refer to [Code of Conduct](https://github.com/agoda-com/Kakao/blob/master/CODE_OF_CONDUCT.md) document.\n\n### License\n\nKakao is open source and available under the [Apache License, Version 2.0](https://github.com/agoda-com/Kakao/blob/master/LICENSE).\n\n### Thanks to\n\n* [Unlimity](https://github.com/Unlimity) - **Ilya Lim** \n* [Vacxe](https://github.com/Vacxe) - **Konstantin Aksenov** \n* [Сdsap](https://github.com/cdsap) - **Inaki Villar** \n* [VerachadW](https://github.com/VerachadW) - **Verachad Wongsawangtham**\n* [JuDrummer](https://github.com/judrummer) - **Tipatai Puthanukunkit** \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagoda-com%2Fkakao","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagoda-com%2Fkakao","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagoda-com%2Fkakao/lists"}