diff --git a/README.md b/README.md index 5eaca206d..af237945a 100644 --- a/README.md +++ b/README.md @@ -5,30 +5,40 @@ ![Build and Deploy](https://github.com/KasperskyLab/Kaspresso/workflows/Build%20and%20Deploy/badge.svg) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=RU&color=0088CC)](https://t.me/kaspresso) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=EN&color=0088CC)](https://t.me/kaspresso_en) +[![Discord](https://img.shields.io/discord/1152145101825527839?label=discord&labelColor=7289da&style=flat)](https://discord.com/invite/hFMC5NQU) # Kaspresso Kaspresso is a framework for Android UI testing. Based on [Espresso](https://developer.android.com/training/testing/espresso) and [UI Automator](https://developer.android.com/training/testing/ui-automator), Kaspresso provides a wide range of additional features, such as: -* 100% stability, no flakiness. -* Jetpack Compose support. +* Built-in protection against flaky tests +* Jetpack Compose support +* Screenshot testing with native approach (with dark mode support) +* Declarative approach for writing tests +* Ability to interact with other applications and system elements and interfaces +* Human readability with Kotlin DSL wrappers over UiAutomator and Espresso +* Detailed logs and reports (logs, view hierarchy, screenshots, video etc.) +* ADB support +* Allure support +* Robolectric support +* Easy migration from Espresso +* Flexible configuration options +* Automatic artifacts pulling after tests execution * Significantly faster execution of UI Automator commands. With Kaspresso, some UI Automator commands run **10 times faster**! -* Excellent readability due to human DSL. -* Useful interceptor mechanism to catch all actions and assertions in one place. -* Full logging. -* Ability to call ADB commands. -* UI tests writing philosophy implemented with DSL. -* Features screenshotting. -* Robolectric support. -* Allure support. +* Page object pattern from the box And many more! Kaspresso +
+ + ## Integration + + To integrate Kaspresso into your project: 1. If the `mavenCentral` repository does not exist, include it to your root `build.gradle` file: @@ -52,7 +62,7 @@ dependencies { } ``` -To try out the cutting edge kaspresso updates before an oficial release add a "-SNAPHOT" postfix to the latest Kaspresso version e.g. +To try out the cutting edge kaspresso updates before an official release add a "-SNAPHOT" postfix to the latest Kaspresso version e.g. ```groovy dependencies { androidTestImplementation 'com.kaspersky.android-components:kaspresso:-SNAPSHOT' @@ -69,13 +79,30 @@ dependencies { } ``` +
+ +## FAQ +[See our website.](https://kasperskylab.github.io/Kaspresso/en/) +You can also reach out to us on [Discord](https://kas.pr/gh_discord). + ## Tutorial *NEW* To make it easier to learn the framework, a step-by-step tutorial is available on [our website](https://kasperskylab.github.io/Kaspresso/Tutorial/). + +
+ + ## Capabilities of Kaspresso + + +
+ + ### Readability + + We like the syntax that [Kakao](https://github.com/KakaoCup/Kakao) applies to write UI tests. This wrapper over Espresso uses the Kotlin DSL approach, that makes the code significantly shorter and more readable. See the difference: @@ -182,21 +209,42 @@ fun shouldPassOnNoInternetScanTest() = } ``` +
+ +
+ + ### Stability + + Sometimes your UI test passes ten times, then breaks on the eleventh attempt for some mysterious reason. It’s called *flakiness*. The most popular reason for flakiness is the instability of the UI tests libraries, such as Espresso and UI Automator. To eliminate this instability, Kaspresso uses DSL wrappers and [interceptors](#Interceptors). +
+ + +
+ + ### UI test libraries acceleration + + Let’s watch some short video that shows the difference between the original UI Automator (on the right) and the accelerated one (on the left). ![](https://habrastorage.org/webt/ti/kv/ki/tikvkij1vjesnacrxqm-lk0coly.gif) Here is [a short explanation](https://kasperskylab.github.io/Kaspresso/Wiki/Kautomator-wrapper_over_UI_Automator/#accelerate-ui-automator) of why it is possible. +
+ +
+ + ### Interceptors + We developed [Kaspresso behavior interceptors](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#some-words-about-behavior-interceptors) on the base of [Kakao/Kautomator Interceptors](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#kaspresso-interceptors-based-on-kakaokautomator-interceptors) to catch failures. @@ -208,17 +256,36 @@ Thanks to interceptors, you can do a lot of useful things, such as: and many more (see [the manual](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#kaspresso-interceptors-based-on-kakaokautomator-interceptors)). +
+ +
+ + ### Writing readable logs + + Kaspresso writes its own logs, detailed and readable: +
+ +
+ + ### Ability to call ADB commands + Espresso and UI Automator don't allow to call ADB commands from inside a test. To fix this problem, we developed AdbServer (see the [wiki](https://kasperskylab.github.io/Kaspresso/Wiki/Executing_adb_commands/)). +
+ +
+ + ### Ability to work with Android System + You can use Kaspresso classes to work with Android System. @@ -237,35 +304,68 @@ For example, with the ```Device``` class you can: (see more about the [Device class](https://kasperskylab.github.io/Kaspresso/Wiki/Working_with_Android_OS/)). +
+ +
+ + ### Features screenshotting + If you develop an application that is available across the world, you have to *localize* it into different languages. When UI is localized, it’s important for the translator to see the context of a word or a phrase, that is the specific screen. With Kaspresso, translators can automatically take a screenshot of any screen. It’s incredibly fast, even for legacy screens, and you don't have to refactor or mock anything (see [the manual](https://kasperskylab.github.io/Kaspresso/Wiki/Screenshot_tests/)). +
+ +
+ + ### Configurability + You can tune any part of Kaspresso (read [more](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/)). +
+ +
+ + ### Robolectric support + You can run your UI-tests on the JVM environment. Additionally, almost all interceptors improving stability, readability and other will work. Read [more](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_Robolectric/). +
+ +
+ + ### Allure support + Kaspresso can generate very detailed Allure-reports for each test: ![](https://habrastorage.org/webt/tq/t7/ch/tqt7chcdczrgduhoukqhx1ertfc.png) More information is available [here](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_Allure/). +
+ +
+ + ### Jetpack Compose support + Now, you can write your Kaspresso tests for Jetpack Compose screens! DSL and all principles are the same. So, you will not see any difference between tests for View screens and for Compose screens. More information is available [here](https://kasperskylab.github.io/Kaspresso/Wiki/Jetpack_Compose/). +
+
+ ## Samples -All samples are available in the [samples](https://github.com/KasperskyLab/Kaspresso/tree/issue-372/tutorial/samples) folder. +All samples are available in the [samples](https://github.com/KasperskyLab/Kaspresso/tree/master/samples) folder. Most of the samples require AdbServer. To start AdbServer you should do the following steps: @@ -278,10 +378,6 @@ cd ~/Workspace/Kaspresso java -jar artifacts/adbserver-desktop.jar ``` -## Runner -If you looking for a Runner to execute your UI tests we strongly recommend to use [Marathon](https://github.com/MarathonLabs/marathon). [Marathon](https://github.com/MarathonLabs/marathon) is a fast, platform-independent test runner focused on performance and stability. It offers easy to use platform implementations for Android and iOS as well as an API for use with custom hardware farms and more techstacks. -Marathon - ## Existing issues All existing issues in Kaspresso can be found [here](https://kasperskylab.github.io/Kaspresso/Issues/). @@ -293,3 +389,15 @@ Kaspresso is an open source project, so you are welcome to contribute (see the [ ## License Kaspresso is available under the [Apache License, Version 2.0](https://github.com/KasperskyLab/Kaspresso/blob/master/LICENSE). + + +
+ + +## Runner + + +If you looking for a Runner to execute your UI tests we strongly recommend to use [Marathon](https://github.com/MarathonLabs/marathon). [Marathon](https://github.com/MarathonLabs/marathon) is a fast, platform-independent test runner focused on performance and stability. It offers easy to use platform implementations for Android and iOS as well as an API for use with custom hardware farms and more techstacks. +Marathon + +
diff --git a/docs/Home/Kaspresso-in-articles.en.md b/docs/Home/Kaspresso-in-articles.en.md index 8413cf9e2..b816746cb 100644 --- a/docs/Home/Kaspresso-in-articles.en.md +++ b/docs/Home/Kaspresso-in-articles.en.md @@ -1,10 +1,19 @@ # Kaspresso in articles - +[EN] [Eugene Matsyuk — Kaspresso: The autotest framework that you have been looking forward to. Part I](https://proandroiddev.com/kaspresso-the-autotest-framework-that-you-have-been-looking-forward-to-part-i-e102ed384d11)
+[EN] [Feyza Dayan - UI Test Roadmap with Kaspresso](https://medium.com/trendyol-tech/ui-test-roadmap-with-kaspresso-fa78d4ee7150)
+[EN] [Kaspersky makes Android app testing tool publicly available for mobile developers](https://www.digitalstreetsa.com/kaspersky-makes-android-app-testing-tool-publicly-available-for-mobile-developers/)
+[EN] [Danil Perevalov - Leak detection into UI tests](https://proandroiddev.com/leak-detection-into-ui-tests-952c598dcfe0)
+[EN] [Christina Rozenkova - Kaspresso Tutorials. Part 1. Launching the First Test](https://proandroiddev.com/kaspresso-tutorials-part-1-launching-the-first-test-731d489ea1ae)
+[EN] [Evgenii Matsiuk (Eugene Matsyuk) - Autotests on Android. The entire picture](https://proandroiddev.com/where-to-write-android-ui-tests-part-2-cb45033f3ddf)
+[EN] [Senchurin Nick - Kaspresso and ADB server](https://proandroiddev.com/kaspresso-and-adb-server-7c35a80d8978)
[RU] [Евгений Мацюк — Kaspresso: фреймворк для автотестирования, который вы ждали](https://habr.com/ru/company/kaspersky/blog/467617/)
[RU] [Иван Федянин — Kaspresso tutorials. Часть 1. Запуск первого теста](https://habr.com/ru/company/kaspersky/blog/570658/)
-[EN] [Eugene Matsyuk — Kaspresso: The autotest framework that you have been looking forward to. Part I](https://proandroiddev.com/kaspresso-the-autotest-framework-that-you-have-been-looking-forward-to-part-i-e102ed384d11)
+[RU] [Евгений Мацюк — Что там по автотестам на Android в 2022?](https://habr.com/ru/articles/695244/)
+[RU] [Konstantin Sidorov - Путь к автотестированию Android нативными инструментами: испробовали всё, что есть на рынке и сделали свои выводы](https://habr.com/ru/companies/bcs_company/articles/661179/)
+[RU] [Алексей Пак - Настраиваем CI/CD для тестовой инфраструктуры Android](https://habr.com/ru/companies/gazprommedia/articles/739838/)
+[RU] [Егор Курников - На чем писать Android UI-тесты](https://habr.com/ru/companies/avito/articles/516650/)
> Do you want your article to be included in this list? Everything is simple! Write an article, send it to us and we will add it to this list! diff --git a/docs/Home/Kaspresso-in-articles.ru.md b/docs/Home/Kaspresso-in-articles.ru.md index 74b8d8188..11bbcb26f 100644 --- a/docs/Home/Kaspresso-in-articles.ru.md +++ b/docs/Home/Kaspresso-in-articles.ru.md @@ -2,8 +2,18 @@ [RU] [Евгений Мацюк — Kaspresso: фреймворк для автотестирования, который вы ждали](https://habr.com/ru/company/kaspersky/blog/467617/)
[RU] [Иван Федянин — Kaspresso tutorials. Часть 1. Запуск первого теста](https://habr.com/ru/company/kaspersky/blog/570658/)
-[EN] [Eugene Matsyuk — Kaspresso: The autotest framework that you have been looking forward to. Part I](https://proandroiddev.com/kaspresso-the-autotest-framework-that-you-have-been-looking-forward-to-part-i-e102ed384d11)
+[RU] [Евгений Мацюк — Что там по автотестам на Android в 2022?](https://habr.com/ru/articles/695244/)
+[RU] [Konstantin Sidorov - Путь к автотестированию Android нативными инструментами: испробовали всё, что есть на рынке и сделали свои выводы](https://habr.com/ru/companies/bcs_company/articles/661179/)
+[RU] [Алексей Пак - Настраиваем CI/CD для тестовой инфраструктуры Android](https://habr.com/ru/companies/gazprommedia/articles/739838/)
+[RU] [Егор Курников - На чем писать Android UI-тесты](https://habr.com/ru/companies/avito/articles/516650/)
+[EN] [Eugene Matsyuk — Kaspresso: The autotest framework that you have been looking forward to. Part I](https://proandroiddev.com/kaspresso-the-autotest-framework-that-you-have-been-looking-forward-to-part-i-e102ed384d11)
+[EN] [Feyza Dayan - UI Test Roadmap with Kaspresso](https://medium.com/trendyol-tech/ui-test-roadmap-with-kaspresso-fa78d4ee7150)
+[EN] [Kaspersky makes Android app testing tool publicly available for mobile developers](https://www.digitalstreetsa.com/kaspersky-makes-android-app-testing-tool-publicly-available-for-mobile-developers/)
+[EN] [Danil Perevalov - Leak detection into UI tests](https://proandroiddev.com/leak-detection-into-ui-tests-952c598dcfe0)
+[EN] [Christina Rozenkova - Kaspresso Tutorials. Part 1. Launching the First Test](https://proandroiddev.com/kaspresso-tutorials-part-1-launching-the-first-test-731d489ea1ae)
+[EN] [Evgenii Matsiuk (Eugene Matsyuk) - Autotests on Android. The entire picture](https://proandroiddev.com/where-to-write-android-ui-tests-part-2-cb45033f3ddf)
+[EN] [Senchurin Nick - Kaspresso and ADB server](https://proandroiddev.com/kaspresso-and-adb-server-7c35a80d8978)
> Хочешь попасть в этот список? Все просто! Напиши статью про Kaspresso, пришли нам ссылку, и мы добавим её в этот список!
diff --git a/docs/Home/Kaspresso-in-videos.en.md b/docs/Home/Kaspresso-in-videos.en.md index 122430a48..cdf5e7a39 100644 --- a/docs/Home/Kaspresso-in-videos.en.md +++ b/docs/Home/Kaspresso-in-videos.en.md @@ -1,8 +1,13 @@ -# Kaspresso в видео +# Kaspresso in videos + +[EN] [Eugene Matsyuk — How to start writing autotests and not go crazy](https://www.youtube.com/watch?v=xiVDqMlTdbM)
+ [RU] [Дмитрий Мовчан, Евгений Мацюк — Как начать писать автотесты и не сойти с ума](https://youtu.be/q_8UUhVDV7c)
[RU] [Егор Курников — Единственное, что вам нужно для UI-тестирования](https://youtu.be/cTykctRSmuA)
[RU] [Воркшоп по автотестам. 19-12-2019](https://www.youtube.com/watch?v=FExlaWfKENI)
[RU] [Руслан Мингалиев - Live-coding: мобильные автотесты с нуля ](https://www.youtube.com/watch?v=gFPeH2yihDA)
-[RU] ["Kaspresso" с Евгением Мацюком и Егором Курниковым](https://www.youtube.com/watch?v=vHkoxOfwbDg&feature=youtu.be)
-[RU] [Kaspresso: Q&A Session 9.04.20](https://www.youtube.com/watch?v=Jqnn_CDcjK0&feature=youtu.be)
-[EN] [Eugene Matsyuk — How to start writing autotests and not go crazy](https://www.youtube.com/watch?v=xiVDqMlTdbM&feature=youtu.be)
+[RU] ["Kaspresso" с Евгением Мацюком и Егором Курниковым](https://www.youtube.com/watch?v=vHkoxOfwbDg)
+[RU] [Kaspresso: Q&A Session 9.04.20](https://www.youtube.com/watch?v=Jqnn_CDcjK0)
+[RU] [Всё, что вы хотели знать о Kaspresso и UI-тестах под Android. Часть 1](https://www.youtube.com/watch?v=JN-c5hD2ZZ8&t=712s)
+[RU] [Всё, что вы хотели знать о Kaspresso и UI-тестах под Android. Часть 2](https://www.youtube.com/watch?v=kmdyzO8Whfo&t=2025s)
+[RU] [Начинаем писать ui-тесты в Android - Mad Brains Техно](https://www.youtube.com/watch?v=AOgXnq-VII0)
diff --git a/docs/Home/Kaspresso-in-videos.ru.md b/docs/Home/Kaspresso-in-videos.ru.md index e730cc7a2..c74800377 100644 --- a/docs/Home/Kaspresso-in-videos.ru.md +++ b/docs/Home/Kaspresso-in-videos.ru.md @@ -1,8 +1,13 @@ -# Kaspresso в videos +# Kaspresso в видео + [RU] [Дмитрий Мовчан, Евгений Мацюк — Как начать писать автотесты и не сойти с ума](https://youtu.be/q_8UUhVDV7c)
[RU] [Егор Курников — Единственное, что вам нужно для UI-тестирования](https://youtu.be/cTykctRSmuA)
[RU] [Воркшоп по автотестам. 19-12-2019](https://www.youtube.com/watch?v=FExlaWfKENI)
[RU] [Руслан Мингалиев - Live-coding: мобильные автотесты с нуля ](https://www.youtube.com/watch?v=gFPeH2yihDA)
-[RU] ["Kaspresso" с Евгением Мацюком и Егором Курниковым](https://www.youtube.com/watch?v=vHkoxOfwbDg&feature=youtu.be)
-[RU] [Kaspresso: Q&A Session 9.04.20](https://www.youtube.com/watch?v=Jqnn_CDcjK0&feature=youtu.be)
-[EN] [Eugene Matsyuk — How to start writing autotests and not go crazy](https://www.youtube.com/watch?v=xiVDqMlTdbM&feature=youtu.be)
+[RU] ["Kaspresso" с Евгением Мацюком и Егором Курниковым](https://www.youtube.com/watch?v=vHkoxOfwbDg)
+[RU] [Kaspresso: Q&A Session 9.04.20](https://www.youtube.com/watch?v=Jqnn_CDcjK0)
+[RU] [Всё, что вы хотели знать о Kaspresso и UI-тестах под Android. Часть 1](https://www.youtube.com/watch?v=JN-c5hD2ZZ8&t=712s)
+[RU] [Всё, что вы хотели знать о Kaspresso и UI-тестах под Android. Часть 2](https://www.youtube.com/watch?v=kmdyzO8Whfo&t=2025s)
+[RU] [Начинаем писать ui-тесты в Android - Mad Brains Техно](https://www.youtube.com/watch?v=AOgXnq-VII0)
+ +[EN] [Eugene Matsyuk — How to start writing autotests and not go crazy](https://www.youtube.com/watch?v=xiVDqMlTdbM)
diff --git a/docs/Tutorial/Scenario.en.md b/docs/Tutorial/Scenario.en.md index cb2ccc211..04dbca4df 100644 --- a/docs/Tutorial/Scenario.en.md +++ b/docs/Tutorial/Scenario.en.md @@ -2,7 +2,7 @@ In this lesson, we will learn what scenarios are (the `Scenario` class from the Kaspresso library), find out what their purpose is, when they should be used, and when it is better to avoid them. -Open the tutorial application and click on the `Login Acitivity` button. +Open the tutorial application and click on the `Login Activity` button. Main Screen login button diff --git a/docs/Tutorial/Scenario.ru.md b/docs/Tutorial/Scenario.ru.md index 3a7bf46a9..31f71993b 100644 --- a/docs/Tutorial/Scenario.ru.md +++ b/docs/Tutorial/Scenario.ru.md @@ -2,7 +2,7 @@ В этом уроке мы познакомимся со сценариями (класс `Scenario` из библиотеки Kaspresso), узнаем, что это, для чего они нужны, когда их стоит использовать, а когда лучше избегать. -Открываем приложение tutorial и кликаем по кнопке `Login Acitivity`. +Открываем приложение tutorial и кликаем по кнопке `Login Activity`. Main Screen login button diff --git a/docs/Tutorial/Writing_simple_test.ru.md b/docs/Tutorial/Writing_simple_test.ru.md index b2b6beaac..8ab0a9072 100644 --- a/docs/Tutorial/Writing_simple_test.ru.md +++ b/docs/Tutorial/Writing_simple_test.ru.md @@ -233,7 +233,7 @@ object MainScreen : KScreen() { Идем дальше, эту кнопку тест должен найти на экране по какому-то критерию. В данном случае мы осуществим поиск элемента по id, поэтому используем матчер `withId`, куда в качестве параметра передаем идентификатор кнопки, который мы нашли благодаря `Layout Inpector`. -Для того чтобы указать этот id, мы использовали синтаксис R.id..., где `R` - это класс со всеми ресурсами приложения. Благодаря нему можно находить id элементов интерфейса, строк, которые есть в проекте, картинок и т.д. При вводе названия этого класса Android Studio должна импортировать его автоматически, но иногда этого не происходит, тогда нужно ввести этот импорт вручную. +Для того чтобы указать этот id, мы использовали синтаксис R.id..., где `R` - это класс со всеми ресурсами приложения. Благодаря ему можно находить id элементов интерфейса, строк, которые есть в проекте, картинок и т.д. При вводе названия этого класса Android Studio должна импортировать его автоматически, но иногда этого не происходит, тогда нужно ввести этот импорт вручную. ```kotlin import com.kaspersky.kaspresso.tutorial.R @@ -316,7 +316,7 @@ class SimpleActivityTest : TestCase() { Feailed test -Дело в том, что Page Object `MainScreen` относится к `MainActivity` (именно эту активити видит пользователь, когда запускает приложение) и, для того чтобы элементы отобразились на экране, эту активити нужно запустить перед выполнением теста. Для того, чтобы перед тестом была запущена какая-то активити, ножно добавить следующие строки: +Дело в том, что Page Object `MainScreen` относится к `MainActivity` (именно эту активити видит пользователь, когда запускает приложение) и, для того чтобы элементы отобразились на экране, эту активити нужно запустить перед выполнением теста. Для того, чтобы перед тестом была запущена какая-то активити, нужно добавить следующие строки: ```kotlin @get:Rule diff --git a/docs/Wiki/Screenshot_tests.en.md b/docs/Wiki/Screenshot_tests.en.md index 2f5f4299a..25d7bee10 100644 --- a/docs/Wiki/Screenshot_tests.en.md +++ b/docs/Wiki/Screenshot_tests.en.md @@ -42,7 +42,7 @@ class ScreenshotSampleTest : DocLocScreenshotTestCase( There is one parameter passed in the base constructor: - locales - comma-separated string with locales to run test with. - Captured screenshots will be available in the device's storage at the path "/sdcard/screenshots/". + Captured screenshots will be available in the device's storage at the path "/sdcard/documents/screenshots/". For full example, check the [ScreenshotSampleTest](../samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/docloc_tests/ScreenshotSampleTest.kt). @@ -211,7 +211,7 @@ For full example, check [AdvancedScreenshotSampleTest](https://github.com/Kasper ## Modifying screenshots path and name By default, all screenshots are stored at:
-```/sdcard/screenshots///.```
+```/sdcard/documents/screenshots///.```
You can change this behavior by providing custom [ResourcesRootDirsProvider](https://github.com/KasperskyLab/Kaspresso/blob/master/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/files/resources/ResourcesRootDirsProvider.kt), [ResourcesDirsProvider](https://github.com/KasperskyLab/Kaspresso/blob/master/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/files/resources/ResourcesDirsProvider.kt), diff --git a/docs/Wiki/Screenshot_tests.ru.md b/docs/Wiki/Screenshot_tests.ru.md index 2135774be..6385d9a52 100644 --- a/docs/Wiki/Screenshot_tests.ru.md +++ b/docs/Wiki/Screenshot_tests.ru.md @@ -37,7 +37,7 @@ class ScreenshotSampleTest : DocLocScreenshotTestCase( } ``` -В базовый конструктор передается один параметр: `locales` - строка с разделенными запятыми локалями для запуска теста. Сделанные скриншоты будут доступны в памяти устройства по пути `/sdcard/screenshots/`. +В базовый конструктор передается один параметр: `locales` - строка с разделенными запятыми локалями для запуска теста. Сделанные скриншоты будут доступны в памяти устройства по пути `/sdcard/documents/screenshots/`. Полный пример см. в [ScreenshotSampleTest](https://github.com/KasperskyLab/Kaspresso/blob/1c1fc42f704ea6baa08e5c0e4e0269ded9243986/samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/docloc_tests/ScreenshotSampleTest.kt). @@ -199,7 +199,7 @@ class AdvancedScreenshotSampleTest : ProductDocLocScreenshotTestCase() { ## Изменение пути и имени скриншотов По умолчанию все скриншоты хранятся по адресу:
-```/sdcard/screenshots///.```
+```/sdcard/documents/screenshots///.```
Вы можете изменить это поведение, предоставив свою реализацию интерфейсов [ResourcesRootDirsProvider](https://github.com/KasperskyLab/Kaspresso/blob/master/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/files/resources/ResourcesRootDirsProvider.kt), [ResourcesDirsProvider](https://github.com/KasperskyLab/Kaspresso/blob/master/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/files/resources/ResourcesDirsProvider.kt), diff --git a/docs/index.en.md b/docs/index.en.md index 1a55dd51c..46cc964a9 100644 --- a/docs/index.en.md +++ b/docs/index.en.md @@ -6,30 +6,38 @@ ![Build and Deploy](https://github.com/KasperskyLab/Kaspresso/workflows/Build%20and%20Deploy/badge.svg) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=RU&color=0088CC)](https://t.me/kaspresso) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=EN&color=0088CC)](https://t.me/kaspresso_en) +[![Discord](https://img.shields.io/discord/1152145101825527839?label=discord&labelColor=7289da&style=flat)](https://discord.com/invite/hFMC5NQU) # Kaspresso -Kaspresso is a framework for Android UI testing. Based on [Espresso](https://developer.android.com/training/testing/espresso) and [UI +Kaspresso is a framework for Android UI testing. Based on [Espresso](https://developer.android.com/training/testing/espresso) and [UI Automator](https://developer.android.com/training/testing/ui-automator), Kaspresso provides a wide range of additional features, such as: -* 100% stability, no flakiness. -* Jetpack Compose support. +* Built-in protection against flaky tests +* Jetpack Compose support +* Screenshot testing with native approach (with dark mode support) +* Declarative approach for writing tests +* Ability to interact with other applications and system elements and interfaces +* Human readability with Kotlin DSL wrappers over UiAutomator and Espresso +* Detailed logs and reports (logs, view hierarchy, screenshots, video etc.) +* ADB support +* Allure support +* Robolectric support +* Easy migration from Espresso +* Flexible configuration options +* Automatic artifacts pulling after tests execution * Significantly faster execution of UI Automator commands. With Kaspresso, some UI Automator commands run **10 times faster**! -* Excellent readability due to human DSL. -* Useful interceptor mechanism to catch all actions and assertions in one place. -* Full logging. -* Ability to call ADB commands. -* UI tests writing philosophy implemented with DSL. -* Features screenshotting. -* Robolectric support. -* Allure support. +* Page object pattern from the box And many more! Kaspresso -[//]: # (![Kaspresso](https://habrastorage.org/webt/dw/jh/9k/dwjh9kypjl637kxj8tiaxwjvtp0.png)) + +
+ ## Integration + To integrate Kaspresso into your project: 1. If the `mavenCentral` repository does not exist, include it to your root `build.gradle` file: @@ -54,7 +62,7 @@ dependencies { } ``` -To try out the cutting edge kaspresso updates before an oficial release add a "-SNAPHOT" postfix to the latest Kaspresso version e.g. +To try out the cutting edge kaspresso updates before an official release add a "-SNAPHOT" postfix to the latest Kaspresso version e.g. ```groovy dependencies { androidTestImplementation 'com.kaspersky.android-components:kaspresso:-SNAPSHOT' @@ -71,14 +79,26 @@ dependencies { } ``` +
+ +## FAQ +For all questions you can reach out to us on [Discord](https://kas.pr/gh_discord). + ## Tutorial *NEW* -To make it easier to learn the framework, a step-by-step tutorial is available on [our website](https://kasperskylab.github.io/Kaspresso/Tutorial/). +To make it easier to learn the framework, a step-by-step tutorial is available on [our website](https://kasperskylab.github.io/Kaspresso/Tutorial/). + +
+ ## Capabilities of Kaspresso + -### Readability +
+ -We like the syntax that [Kakao](https://github.com/KakaoCup/Kakao) applies to write UI tests. This wrapper over Espresso uses the Kotlin DSL approach, that makes the code +### Readability + +We like the syntax that [Kakao](https://github.com/KakaoCup/Kakao) applies to write UI tests. This wrapper over Espresso uses the Kotlin DSL approach, that makes the code significantly shorter and more readable. See the difference: **Espresso**: @@ -134,7 +154,7 @@ MainScreen { Since Kakao and Kautomator provide almost identical APIs, you don’t have to care about what is under the hood of your tests, either Espresso or UI Automator. With Kaspresso, you write tests in the same style for both. However, Kakao and Kautomator themselves don't help you to see the relation between the test and the corresponding test case. Also, a long test often becomes a giant piece of code that is impossible to split into smaller parts. -That's why we have created an additional Kotlin DSL that allows you to read your test more easily. +That's why we have created an additional Kotlin DSL that allows you to read your test more easily. See the example below: @@ -184,13 +204,25 @@ fun shouldPassOnNoInternetScanTest() = } ``` -### Stability +
+ +
+ + +### Stability + + +Sometimes your UI test passes ten times, then breaks on the eleventh attempt for some mysterious reason. It’s called *flakiness*. -Sometimes your UI test passes ten times, then breaks on the eleventh attempt for some mysterious reason. It’s called *flakiness*. +The most popular reason for flakiness is the instability of the UI tests libraries, such as Espresso and UI Automator. To eliminate this instability, Kaspresso uses DSL wrappers and [interceptors](#Interceptors). -The most popular reason for flakiness is the instability of the UI tests libraries, such as Espresso and UI Automator. To eliminate this instability, Kaspresso uses DSL wrappers and [interceptors](#Interceptors). +
+ +
+ ### UI test libraries acceleration + Let’s watch some short video that shows the difference between the original UI Automator (on the right) and the accelerated one (on the left). @@ -198,9 +230,15 @@ Let’s watch some short video that shows the difference between the original UI Here is [a short explanation](https://kasperskylab.github.io/Kaspresso/Wiki/Kautomator-wrapper_over_UI_Automator/#accelerate-ui-automator) of why it is possible. +
+ +
+ + ### Interceptors + -We developed [Kaspresso behavior interceptors](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#some-words-about-behavior-interceptors) on the base of [Kakao/Kautomator +We developed [Kaspresso behavior interceptors](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#some-words-about-behavior-interceptors) on the base of [Kakao/Kautomator Interceptors](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#kaspresso-interceptors-based-on-kakaokautomator-interceptors) to catch failures. Thanks to interceptors, you can do a lot of useful things, such as: @@ -210,17 +248,36 @@ Thanks to interceptors, you can do a lot of useful things, such as: and many more (see [the manual](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/#kaspresso-interceptors-based-on-kakaokautomator-interceptors)). +
+ +
+ + ### Writing readable logs + + Kaspresso writes its own logs, detailed and readable: +
+ +
+ + ### Ability to call ADB commands + Espresso and UI Automator don't allow to call ADB commands from inside a test. To fix this problem, we developed AdbServer (see the [wiki](https://kasperskylab.github.io/Kaspresso/Wiki/Executing_adb_commands/)). +
+ +
+ + ### Ability to work with Android System + You can use Kaspresso classes to work with Android System. @@ -239,46 +296,68 @@ For example, with the ```Device``` class you can: (see more about the [Device class](https://kasperskylab.github.io/Kaspresso/Wiki/Working_with_Android_OS/)). +
+ +
+ + ### Features screenshotting + -If you develop an application that is available across the world, you have to *localize* it into different languages. When UI is localized, it’s important for the translator to see the context of a word or a phrase, that is the specific screen. +If you develop an application that is available across the world, you have to *localize* it into different languages. When UI is localized, it’s important for the translator to see the context of a word or a phrase, that is the specific screen. With Kaspresso, translators can automatically take a screenshot of any screen. It’s incredibly fast, even for legacy screens, and you don't have to refactor or mock anything (see [the manual](https://kasperskylab.github.io/Kaspresso/Wiki/Screenshot_tests/)). +
+ +
+ + ### Configurability + You can tune any part of Kaspresso (read [more](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_configuration/)). +
+ +
+ + ### Robolectric support + -You can run your UI-tests on the JVM environment. Additionally, almost all interceptors improving stability, readability and other will work. -Read [more](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_Robolectric/). +You can run your UI-tests on the JVM environment. Additionally, almost all interceptors improving stability, readability and other will work. +Read [more](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_Robolectric/). + +
+ +
+ ### Allure support + Kaspresso can generate very detailed Allure-reports for each test: ![](https://habrastorage.org/webt/tq/t7/ch/tqt7chcdczrgduhoukqhx1ertfc.png) -More information is available [here](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_Allure/). +More information is available [here](https://kasperskylab.github.io/Kaspresso/Wiki/Kaspresso_Allure/). + +
+ +
+ ### Jetpack Compose support + -Now, you can write your Kaspresso tests for Jetpack Compose screens! DSL and all principles are the same. +Now, you can write your Kaspresso tests for Jetpack Compose screens! DSL and all principles are the same. So, you will not see any difference between tests for View screens and for Compose screens. More information is available [here](https://kasperskylab.github.io/Kaspresso/Wiki/Jetpack_Compose/). -**Keep in mind it's early access that may contain bugs. Also, API can be changed, but we are going to avoid it. Be free to create relative issues if you've encountered with -any kind of problem.** - -## Philosophy - -The tool itself, even the perfect one, can not solve all the problems in writing UI tests. It’s important to know how to write tests and how to organize the entire process. -Our team has great experience in introducing autotests in different companies. We shared our knowledge on [Wiki](https://kasperskylab.github.io/Kaspresso/Wiki/). - -## Wiki -For all information check [Kaspresso wiki](https://kasperskylab.github.io/Kaspresso/Wiki/) +
+
## Samples -All samples are available in the [samples](https://github.com/KasperskyLab/Kaspresso/tree/issue-372/tutorial/samples) folder. +All samples are available in the [samples](https://github.com/KasperskyLab/Kaspresso/tree/master/samples) folder. Most of the samples require AdbServer. To start AdbServer you should do the following steps: @@ -294,7 +373,7 @@ java -jar artifacts/adbserver-desktop.jar ## Existing issues All existing issues in Kaspresso can be found [here](https://kasperskylab.github.io/Kaspresso/Issues/). -## Breaking changes +## Breaking changes Breaking changes can be found [here](https://kasperskylab.github.io/Kaspresso/Home/Breaking-changes/) ## Contribution @@ -302,3 +381,7 @@ Kaspresso is an open source project, so you are welcome to contribute (see the [ ## License Kaspresso is available under the [Apache License, Version 2.0](https://github.com/KasperskyLab/Kaspresso/blob/master/LICENSE). + +## Runner +If you looking for a Runner to execute your UI tests we strongly recommend to use [Marathon](https://github.com/MarathonLabs/marathon). [Marathon](https://github.com/MarathonLabs/marathon) is a fast, platform-independent test runner focused on performance and stability. It offers easy to use platform implementations for Android and iOS as well as an API for use with custom hardware farms and more techstacks. +Marathon diff --git a/docs/index.ru.md b/docs/index.ru.md index 0f7d5caff..dce7c7360 100644 --- a/docs/index.ru.md +++ b/docs/index.ru.md @@ -6,29 +6,39 @@ ![Build and Deploy](https://github.com/KasperskyLab/Kaspresso/workflows/Build%20and%20Deploy/badge.svg) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=RU&color=0088CC)](https://t.me/kaspresso) [![Telegram](https://img.shields.io/static/v1?label=Telegram&message=EN&color=0088CC)](https://t.me/kaspresso_en) +[![Discord](https://img.shields.io/discord/1152145101825527839?label=discord&labelColor=7289da&style=flat)](https://discord.com/invite/hFMC5NQU) # Kaspresso Kaspresso — это фреймворк для тестирования пользовательского интерфейса Android. Он основан на [Espresso](https://developer.android.com/training/testing/espresso) и [UI Automator](https://developer.android.com/training/testing/ui-automator) и предоставляет широкий спектр дополнительных функций, таких как: -* 100% стабильность, отсутствие флаков. -* Поддержка Jetpack Compose **[Ранний доступ]**. +* Встроенная защита от флаков в тестах +* Поддержка Jetpack Compose +* Скриншот-тестирование с нативным подходом (с поддержкой тёмной темы) +* Декларативный подход к написанию тестов +* Возможность взаимодействовать с другими приложениями и системными элементами и интерфейсами +* Отличная читаемость благодаря человеческому DSL поверх UiAutomator и Espresso +* Детальные логи и отчеты (логи, иерархия графических элементов на экране, скриншоты, видео и т.д. +* Возможность вызова команд ADB +* Поддержка Allure +* Поддержка Robolectric +* Легкая миграция с Espresso +* Гибкая настройка фреймворка +* Автоматическая выкачка артифактов после прогона тестов * Значительно ускорено выполнение команд UI Automator. С Kaspresso некоторые команды UI Automator выполняются **в 10 раз быстрее**! -* Отличная читаемость благодаря человеческому DSL. +* Реализация паттерна Page Object из коробки * Полезный механизм перехватчиков, позволяющий перехватывать все действия и проверки в одном месте. -* Полное ведение журнала. -* Возможность вызова команд ADB. -* Философия написания тестов пользовательского интерфейса, реализованная с помощью DSL. -* Предоставляет возможность скриншотинга. -* Поддержка Robolectric. -* Поддержка Allure. И многое другое! Kaspresso [//]: # (![Kaspresso](https://habrastorage.org/webt/dw/jh/9k/dwjh9kypjl637kxj8tiaxwjvtp0.png)) +
+ + ## Интеграция + Чтобы интегрировать Kaspresso в свой проект: 1. Включите репозиторий mavenCentral в корневой файл `build.gradle`: @@ -71,13 +81,24 @@ dependencies { } ``` +
+ +## FAQ +Вы можете задать любые вопросы в нашем чате поддержки в [Telegram](https://t.me/kaspresso). + ## Туториал *Новое* -Чтобы упростить изучение фреймворка, доступно пошаговое руководство на [нашем веб-сайте](https://kasperskylab.github.io/Kaspresso/ru/Tutorial/). +Чтобы упростить изучение фреймворка, доступно пошаговое руководство на [нашем веб-сайте](https://kasperskylab.github.io/Kaspresso/ru/Tutorial/). + +
+ ## Возможности Kaspresso + +
+ ### Читаемость - + Нам нравится синтаксис, который [Kakao](https://github.com/KakaoCup/Kakao) применяет для написания тестов пользовательского интерфейса. Эта оболочка над Espresso использует подход Kotlin DSL, что делает код значительно короче и читабельнее. Можно увидеть разницу: @@ -184,13 +205,25 @@ fun shouldPassOnNoInternetScanTest() = } ``` +
+ +
+ + ### Стабильность + Иногда ваш тест может выполняться успешно десять раз, а затем ломается на одиннадцатой попытке по какой-то загадочной причине. Это называется *флак(flakiness)*. Самая популярная причина ненадёжности — нестабильность библиотек UI-тестов, таких как Espresso и UI Automator. Чтобы устранить эту нестабильность, Kaspresso использует DSL обертки и [перехватчики](#Interceptors). +
+ +
+ + ### Ускорение библиотек тестов пользовательского интерфейса + Давайте посмотрим короткое видео, показывающее разницу между оригинальным UI Automator (справа) и ускоренным (слева). @@ -198,7 +231,13 @@ fun shouldPassOnNoInternetScanTest() = Здесь предоставлено [краткое объяснение](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kautomator-wrapper_over_UI_Automator/#ui-automator), почему это возможно. +
+ +
+ + ### Перехватчики + Мы разработали [перехватчики поведения Kaspresso](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kaspresso_configuration/#behavior-interceptors) (Kaspresso behavior interceptors) на основе [перехватчиков Kakao/Kautomator](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kaspresso_configuration/#kaspresso-kakaokautomator) для обработки сбоев. @@ -209,17 +248,36 @@ fun shouldPassOnNoInternetScanTest() = и многое другое (см. [руководство](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kaspresso_configuration/#kaspresso-kakaokautomator)). +
+ +
+ + ### Запись читаемых логов + + Kaspresso пишет собственные сообщения в журнал, подробные и читабельные: +
+ +
+ + ### Возможность вызова команд ADB + Espresso и UI Automator не позволяют вызывать команды ADB из теста. Чтобы решить эту проблему, мы разработали AdbServer (см. [вики](https://kasperskylab.github.io/Kaspresso/Wiki/Executing_adb_commands/)). +
+ +
+ + ### Возможность работы с системой Android + Вы можете использовать классы Kaspresso для работы с системой Android. @@ -238,28 +296,57 @@ Espresso и UI Automator не позволяют вызывать команды (подробнее о [Device class](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Working_with_Android_OS/)). +
+ +
+ + ### Предоставляет возможность скриншотинга + Если вы разрабатываете приложение, доступное по всему миру, вам необходимо *локализировать* его на разные языки. Когда интерфейс локализован, для переводчика важно увидеть контекст слова или фразы на конкретном экране. С Kaspresso переводчики могут автоматически делать скриншот любого экрана. Это невероятно быстро, даже для устаревших экранов, и не требует дополнительного рефакторинга (см. [руководство](https://kasperskylab.github.io/Kaspresso/Wiki/Screenshot_tests/)). +
+ +
+ + ### Конфигурируемость + Вы можете настроить любую часть Kaspresso ([подробнее](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kaspresso_configuration/)). +
+
+ + ### Поддержка Robolectric + Вы можете запускать свои UI-тесты в среде JVM. Кроме того, почти все перехватчики, улучшающие стабильность, читабельность и другие, будут работать. Читать [подробнее](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kaspresso_Robolectric/). +
+ +
+ + ### Поддержка Allure + Kaspresso может генерировать очень подробные Allure-отчеты для каждого теста: ![](https://habrastorage.org/webt/tq/t7/ch/tqt7chcdczrgduhoukqhx1ertfc.png) Более подробная информация доступна [здесь](https://kasperskylab.github.io/Kaspresso/ru/Wiki/Kaspresso_Allure/). +
+ +
+ + ### Поддержка Jetpack Compose (ранний доступ) + Теперь вы можете писать свои тесты Kaspresso для экранов Jetpack Compose! DSL и все принципы одинаковы. Таким образом, вы не увидите никакой разницы между тестами для View и для экранов Compose. @@ -267,16 +354,11 @@ Kaspresso может генерировать очень подробные Allu ** Имейте в виду, что это ранний доступ, который может содержать ошибки. Также возможно изменение API, но мы будем стараться этого не делать. Не стесняйтесь сообщать о багах в разделе issue, если вы столкнулись с какой-либо проблемой.** -## Философия - -Сам инструмент, даже идеальный, не может решить всех проблем написания UI-тестов. Важно знать, как писать тесты и как организовать весь процесс. -Наша команда имеет большой опыт внедрения автотестов в разных компаниях. Мы поделились своими знаниями на [Wiki](https://kasperskylab.github.io/Kaspresso/ru/Wiki/). - -## Вики -Для получения всей информации посетите [Kaspresso wiki](https://kasperskylab.github.io/Kaspresso/ru/Wiki/) +
+
## Примеры -Все примеры доступны в папке [samples](https://github.com/KasperskyLab/Kaspresso/tree/issue-372/tutorial/samples). +Все примеры доступны в папке [samples](https://github.com/KasperskyLab/Kaspresso/tree/issue-372/tutorial/samples). Для большинства примеров требуется AdbServer. Чтобы запустить AdbServer, вы должны сделать следующие шаги: @@ -289,6 +371,13 @@ cd ~/Workspace/Kaspresso java -jar artifacts/adbserver-desktop.jar ``` +## Философия +Сам инструмент, даже идеальный, не может решить всех проблем написания UI-тестов. Важно знать, как писать тесты и как организовать весь процесс. +Наша команда имеет большой опыт внедрения автотестов в разных компаниях. Мы поделились своими знаниями на [Wiki](https://kasperskylab.github.io/Kaspresso/ru/Wiki/). + +## Вики +Для получения всей информации посетите [Kaspresso wiki](https://kasperskylab.github.io/Kaspresso/ru/Wiki/) + ## Существующие проблемы Все существующие проблемы в Kaspresso можно найти [здесь](https://kasperskylab.github.io/Kaspresso/ru/Issues/). diff --git a/docs/kaspresso.png b/docs/kaspresso.png index 74e60208a..8cb83b6ff 100644 Binary files a/docs/kaspresso.png and b/docs/kaspresso.png differ diff --git a/kaspresso.png b/kaspresso.png index 74e60208a..8cb83b6ff 100644 Binary files a/kaspresso.png and b/kaspresso.png differ diff --git a/mkdocs.yml b/mkdocs.yml index 3463f87c6..55e1c974d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -60,12 +60,14 @@ plugins: default_language: en docs_structure: suffix languages: - ru: - name: Russian - build: true - en: + - locale: en + default: true name: English build: true + - locale: ru + default: true + name: Russian + build: true nav_translations: en: Home: Home