Description: Koog is the official Kotlin framework for building predictable, fault-tolerant and enterprise-ready AI agents across all platforms – from backend services to Android and iOS, JVM, and even in-browser environments. Koog is based on our AI products expertise and provides proven solutions for complex LLM and AI problems
View jetbrains/koog on GitHub ↗
Koog is a Kotlin-based DSL (Domain Specific Language) and compiler designed for creating UI tests for Android applications, aiming to replace or augment existing frameworks like Espresso. Developed by JetBrains, it focuses on improving the readability, maintainability, and robustness of UI tests by leveraging Kotlin’s expressive power and a declarative approach to test definition. Instead of writing imperative sequences of actions, Koog allows developers to describe *what* they want to achieve in the UI, and the compiler translates that into Espresso code.
The core principle behind Koog is the use of a type-safe DSL. This means that the actions and assertions available within a Koog test are contextually relevant to the current UI element being interacted with. This drastically reduces the chances of runtime errors caused by incorrect selectors or actions. Koog introduces concepts like `Screen`, `Element`, and `Action` to structure tests. A `Screen` represents a specific state of the application UI, and `Element`s define the UI components within that screen. `Action`s are then used to interact with those elements. The type system ensures that you can only perform valid actions on valid elements, providing compile-time safety.
Koog’s compiler is a key component. It takes the Kotlin DSL code written by the developer and transforms it into equivalent Espresso code. This allows Koog tests to run on existing Android infrastructure without requiring significant changes to the CI/CD pipeline. The compiler handles the complexities of Espresso, such as view matching and action execution, freeing the developer to focus on the test logic itself. A significant benefit is that the generated Espresso code is often more concise and readable than hand-written Espresso tests, even before considering the benefits of Koog’s type safety.
The repository provides a complete toolchain, including the Koog compiler plugin for Gradle, a runtime library, and example projects. The Gradle plugin integrates seamlessly into existing Android projects, allowing developers to easily add Koog tests alongside their existing instrumentation tests. The runtime library provides the necessary support for executing the generated Espresso code. The example projects demonstrate how to use Koog to test various UI scenarios, including simple interactions, complex workflows, and data-driven tests.
Currently, Koog is in early access and actively under development. While it supports a growing set of common UI elements and actions, it doesn't yet cover the full breadth of Espresso's capabilities. The project is open-source, encouraging community contributions and feedback. The roadmap includes expanding the DSL to support more UI components, improving the compiler's performance and error reporting, and adding features like test recording and visual validation. Koog represents a promising approach to UI testing on Android, offering a more modern and developer-friendly experience compared to traditional Espresso-based testing.
Fetching additional details & charts...