All Projects → KasperskyLab → Kaspresso

KasperskyLab / Kaspresso

Licence: apache-2.0
Great UI test framework

Programming Languages

kotlin
9241 projects
dsl
153 projects

Projects that are alternatives of or similar to Kaspresso

The Rest Architectural Style
An article on the REST architecture style.
Stars: ✭ 168 (-83.1%)
Mutual labels:  best-practices, architecture
devonfw4flutter-mts-app
Large-Scale Flutter Reference Application. An Extension of DevonFw's My Thai Star Project
Stars: ✭ 54 (-94.57%)
Mutual labels:  best-practices, architecture
Devonfw4flutter
A guide aiming to bridge the gap between the absolute Flutter basics and clean, structured Flutter Development
Stars: ✭ 219 (-77.97%)
Mutual labels:  best-practices, architecture
Android Modular Architecture
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
Stars: ✭ 2,048 (+106.04%)
Mutual labels:  best-practices, architecture
Android Showcase
💎 Android application following best practices: Kotlin, Coroutines, JetPack, Clean Architecture, Feature Modules, Tests, MVVM, DI, Static Analysis...
Stars: ✭ 5,214 (+424.55%)
Mutual labels:  best-practices, architecture
Domain Driven Hexagon
Guide on Domain-Driven Design, software architecture, design patterns, best practices etc.
Stars: ✭ 4,417 (+344.37%)
Mutual labels:  best-practices, architecture
Java Best Practices
Best practices in Coding, Designing and Architecting Java Applications
Stars: ✭ 909 (-8.55%)
Mutual labels:  best-practices, architecture
Offlinefirstreactiveapp Tutorial
Check out the blog post for more info
Stars: ✭ 120 (-87.93%)
Mutual labels:  architecture, espresso
Microservices Book
"Microservices Architecture for eCommerce" is an Open Source Book on Microservices and Headless eCommerce. Feel invited to contribute! Read online or download a PDF
Stars: ✭ 337 (-66.1%)
Mutual labels:  best-practices, architecture
Avenging
MVP pattern example on Android: no Dagger or RxJava example
Stars: ✭ 279 (-71.93%)
Mutual labels:  architecture, espresso
Ios Good Practices
Good ideas for iOS development, by Futurice developers.
Stars: ✭ 10,417 (+947.99%)
Mutual labels:  best-practices, architecture
React Best Practices
A comprehensive reference guide to kickstart your React architecting career!
Stars: ✭ 566 (-43.06%)
Mutual labels:  best-practices, architecture
Aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
Stars: ✭ 10,061 (+912.17%)
Mutual labels:  best-practices, architecture
Architecture
.NET 6, ASP.NET Core 6, Entity Framework Core 6, C# 10, Angular 13, Clean Code, SOLID, DDD.
Stars: ✭ 2,285 (+129.88%)
Mutual labels:  best-practices, architecture
Architecture Center
Azure Architecture Center
Stars: ✭ 1,207 (+21.43%)
Mutual labels:  best-practices, architecture
Villains-and-Heroes
Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. ⚡
Stars: ✭ 53 (-94.67%)
Mutual labels:  architecture, espresso
Rwdtow
Ruby Web Dev: The Other Way. Personal best practices guide.
Stars: ✭ 267 (-73.14%)
Mutual labels:  best-practices, architecture
Android Starter
[Android Architecture] Android starter based on MVP/Dagger2/RxJava2/Robolectric/Espresso/Mockito. It provides a generator to fast create a Android template project.
Stars: ✭ 522 (-47.48%)
Mutual labels:  architecture, espresso
Onboarding
A list of resources we at flyeralarm use to get new developers up and running
Stars: ✭ 648 (-34.81%)
Mutual labels:  best-practices, architecture
Awesome Seo
Google SEO研究及流量变现
Stars: ✭ 942 (-5.23%)
Mutual labels:  best-practices

Android Arsenal Android Weekly Android Weekly Download Build and Deploy

Kaspresso

Kaspresso is a great framework for UI testing. Based on Espresso and UI Automator, Kaspresso provides a wide range of additional amazing features, such as:

  • 100% stability, no flakiness.
  • Significantly faster execution of UI Automator commands. With Kaspresso, some UI Automator commands run 10 times faster!
  • Excellent readability due to human DSL.
  • Incredible mechanism of interceptors that allows you 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.

And many more!

Kaspresso

Capabilities of Kaspresso

Readability

We like the syntax that 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:

@Test
fun testFirstFeature() {
    onView(withId(R.id.toFirstFeature))
        .check(ViewAssertions.matches(
               ViewMatchers.withEffectiveVisibility(
                       ViewMatchers.Visibility.VISIBLE)))
    onView(withId(R.id.toFirstFeature)).perform(click())
}

Kakao:

@Test
fun testFirstFeature() {
    mainScreen {
        toFirstFeatureButton {
            isVisible()
            click()
        }
    }
}

We used the same approach to develop our own wrapper over UI Automator, and we called it Kautomator. Take a look at the code below:

UI Automator:

val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
val uiDevice = UiDevice.getInstance(instrumentation)

val uiObject = uiDevice.wait(
    Until.findObject(
        By.res(
            "com.kaspersky.kaspresso.sample_kautomator",
            "editText"
        )
    ),
    2_000
)

uiObject.text = "Kaspresso"
assertEquals(uiObject.text, "Kaspresso")

Kautomator:

MainScreen {
    simpleEditText {
        replaceText("Kaspresso")
        hasText("Kaspresso")
    }
}

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 the same tests for both.

Read about Kakao and Kautomator in details.

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.

See the example below:

@Test
fun shouldPassOnNoInternetScanTest() =
    beforeTest {
        activityTestRule.launchActivity(null)
        // some things with the state
    }.afterTest {
        // some things with the state
    }.run {
        step("Open Simple Screen") {
            MainScreen {
                nextButton {
                    isVisible()
                    click()
                }
            }
        }

        step("Click button_1 and check button_2") {
            SimpleScreen {
                button1 {
                    click()
                }
                button2 {
                    isVisible()
                }
            }
        }

        step("Click button_2 and check edit") {
            SimpleScreen {
                button2 {
                    click()
                }
                edit {
                    flakySafely(timeoutMs = 7000) { isVisible() }
                    hasText(R.string.text_edit_text)
                }
            }
        }

        step("Check all possibilities of edit") {
            scenario(
                CheckEditScenario()
            )
        }
    }

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.

Also, some Kaspresso features can help you resolve a lot of typical problems in UI testing.

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).

Here is a short explanation of why it is possible.

Interceptors

We developed Kaspresso behavior interceptors on the base of Kakao/Kautomator Interceptors to catch failures.

Thanks to interceptors, you can do a lot of useful things, such as:

  • add custom actions to each library operation like writing a log or taking a screenshot;
  • overcome flaky library operations by re-running failed actions, scrolling the parent layout or removing the android system dialog;

and many more (see the manual).

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 Autotest AdbServer (see the wiki).

Ability to work with Android System

You can use Kaspresso classes to work with Android System.

For example, with the Device class you can:

  • push/pull files,
  • enable/disable network,
  • give permissions like a user does,
  • emulate phone calls,
  • take screenshots,
  • enable/disable GPS,
  • set geolocation,
  • enable/disable accessibility,
  • change the app language,
  • collect and parse the logcat output.

(see more about the Device class).

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).

Configurability

You can tune any part of Kaspresso (read more)

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 writing autotests.

Wiki

For all information check Kaspresso wiki

Integration

To integrate Kaspresso into your project:

  1. If the jcenter repository does not exist, include it to your root build.gradle file:
allprojects {
    repositories {
        jcenter()
    }
}
  1. Add a dependency to build.gradle:
dependencies {
    androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.2.0'
}

If you are still using the old Android Support libraries, we strongly recommend to migrate to AndroidX.

The last version with Android Support libraries is:

dependencies {
    androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.0.1-support'
}

Snapshots

Snapshots are available via https://oss.jfrog.org/artifactory/libs-snapshot/com/kaspersky/android-components/

repositories {
    maven { url 'https://oss.jfrog.org/libs-snapshot' }
}

dependencies {
    androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.2.1-SNAPSHOT'
}

Samples

All samples are available in the samples folder.

Most of the samples require AdbServer. To start AdbServer you should do the following steps:

  1. Go to the Kaspresso folder
cd ~/Workspace/Kaspresso
  1. Start adbserver-desktop.jar
java -jar artifacts/adbserver-desktop.jar

Breaking changes in 1.2.0

  1. We've totally reworked AdbServer and Kaspresso 1.2.0 works only with new artifacts/adbserver-desktop.jar
    The old version artifacts/desktop_1_1_0.jar is also available for use with older versions of Kaspresso.
  2. If you use device.logcat in your tests, you should call device.logcat.disableChatty in the before section of your test. In previous version of Kaspresso, device.logcat.disableChatty was called automatically during initialization. This resulted in the need to always run AdbServer before tests.

Support

Ask your question on Telegram:

  • In English: t.me/kaspresso_en
  • In Russian: t.me/kaspresso

Contribution

Kaspresso is an open source project, so you are welcome to contribute (see the Contribution Guidelines).

License

Kaspresso is available under the Apache License, Version 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].