Super Heroes Kata for Android Developers in Kotlin. The main goal is to practice UI Testing.

Overview

Karumi logo KataSuperHeroes in Kotlin Build Status

  • We are here to practice UI Testing.
  • We are going to use Espresso to interact with the Application UI.
  • We are going to use Kodein to replace production code with Test Doubles.
  • We are going to practice pair programming.

Getting started

This repository contains an Android application to show Super Heroes information:

ApplicationScreencast

This Application is based on two Activities:

  • MainActivity showing a list of super heroes with name, photo and a special badge if is part of the Avengers Team.

MainActivityScreenhot

  • SuperHeroDetailActivity showing detailed information about a super hero like his or her name, photo and description.

SuperHeroDetailActivityScreenshot

The application architecture, dependencies and configuration is ready to just start writing tests. In this project you'll find Kodein configured to be able to replace production code with test doubles easily and Espresso to be able to interact with the application user interface.

Tasks

Your task as Android Developer is to write all the UI tests needed to check if the Application UI is working as expected.

This repository is ready to build the application, pass the checkstyle and your tests in Travis-CI environments.

Our recommendation for this exercise is:

  • Before starting

    1. Fork this repository.
    2. Checkout kata-super-heroes branch.
    3. Execute the application, explore it manually and make yourself familiar with the code.
    4. Execute MainActivityTest and watch the only test it contains pass.
  • To help you get started, these are some test cases for MainActivity:

    1. Setup mocked SuperHeroRepository in MainActivityTest to return a list of some Super Heroes.
    2. Test that RecyclerView is listing the correct number of elements when SuperHeroesRepository returns a list of some Super Heroes.
    3. Test that each of this elements contains the correct Super Hero name.

Considerations

  • If you get stuck, master branch contains already solved tests for MainActivity and SuperHeroDetailActivity

  • You will find some utilities to help you test RecyclerViews and Toolbars easily in: app/src/androidTest/java/com/karumi/matchers and app/src/androidTest/java/com/karumi/recyclerview.

    • RecyclerViewInteraction: provides an easy way to apply an Espresso matcher to all of the RecyclerView elements

      RecyclerViewInteraction.onRecyclerView<ITEM_TYPE>(withId(R.id.recycler_view))
                  .withItems(A_LIST_OF_ITEMS)
                  .check({ item, view, e -> matches(A_MATCHER).check(view, e) })
    • RecyclerViewItemsCountMatcher: a matcher that returns true if RecyclerView contains the expected number of elements.

    • ToolbarMatcher: a matcher that returns true if a Toolbar with expected title is found.

Extra Tasks

If you've covered all the application functionality using UI tests try to continue with the following tasks:

  • Add a pull to refresh mechanism to MainActivity and test it.
  • Modify SuperHeroDetailActivity to handle an error case where the name of the super hero used to start this activity does not exist and show a message if this happens.
  • Modify the project to handle connection errors and show a SnackBar to indicate something went wrong.
  • Modify SuperHeroesRepository test double to perform a Thread.sleep and use the custom idling resources you'll find in this repository to get your tests working.

Documentation

There are some links which can be useful to finish these tasks:

Data provided by Marvel. © 2017 MARVEL

License

Copyright 2017 Karumi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • Include mockito-kotlin

    Include mockito-kotlin

    The main reason being that we won't need our own on function and use mockito-kotlin's function whenever (https://github.com/nhaarman/mockito-kotlin/wiki/Mocking-and-verifying#stubbing)

    enhancement help wanted good first issue 
    opened by Serchinastico 1
  • Update dependencies on kata super heroes

    Update dependencies on kata super heroes

    See #5

    Besides that:

    • I'm changing the way we are using coroutines because we were blocking the UI with the previous implementation.
    • I'm removing the custom implementation of the lifecycle subscription because it has a bug where the loading view stays forever due to an activity leak. I'm using now the lifecycle component of jetpack

    I'm porting these fixes to master as well. Hopefully we get travis back to our side with this PR :)

    opened by Serchinastico 0
  • Update dependencies on master

    Update dependencies on master

    • Update general dependencies
    • Update kotlin version
    • Update gradle and gradle plugin versions
    • Update coroutines lib version to stable
    • Fix all linting issues
    • Update travis configuration file to match the new Android SDK versions
    • Fix dex opener configuration
    • Get rid of the mockito extension on and use whenever found in mockito-kotlin instead.
    opened by Serchinastico 0
  • Create base tests

    Create base tests

    :cyclone: Git merge message

    • Create tests for the MainActivity class
    • Create tests for the SuperHeroDetailActivity class
    • Configure dependencies to run espresso acceptance tests
    opened by Serchinastico 0
  • Update Espresso version

    Update Espresso version

    During the last training some attendees found dependency management errors due to the espresso version. We should update to the latest one before the next training.

    opened by pedrovgs 1
Owner
Karumi
Karumi, the Rock Solid Code studio
Karumi
Screenshot Kata for Android Developers with Kotlin. The main goal is to practice UI Screenshot Testing.

KataScreenshot in Kotlin We are here to practice UI testing using screenshot tests for Android. We are going to use Espresso to interact with the Appl

Karumi 76 Nov 20, 2022
Maxibon kata for Kotlin Developers. The main goal is to practice property based testing.

Kata Maxibon for Kotlin. We are here to practice property based testing. We are going to use KotlinTest to write our tests. We are going to practice p

Karumi 44 Oct 3, 2022
TODO API Client Kata for Kotlin Developers. The main goal is to practice integration testing using MockWebServer

KataTODOApiClient for Kotlin We are here to practice integration testsing using HTTP stubbing. We are going to use MockWebServer to simulate a HTTP se

Karumi 61 Nov 20, 2022
KataContacts written in Kotlin. The main goal is to practice Clean Architecture Development

KataContacts written in Kotlin We are here to practice Clean Architecture Development. Clean Architecture is a way of structuring code. We are going t

Karumi 48 Oct 3, 2022
🔥The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.

??The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.

Rouse 1.3k Dec 30, 2022
❤️ A sample Marvel heroes application based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.

MarvelHeroes MarvelHeroes is a demo application based on modern Android application tech-stacks and MVVM architecture. Fetching data from the network

Jaewoong Eum 1.2k Dec 19, 2022
A korge map generator for Pocket Palm Heroes remastered

Korge mapgen This is a korge map generator for Pocket Palm Heroes remastered. Algorithm Is based mostly on this presentation by Gus Smedstad, who is t

Alexey Kononov 4 Sep 6, 2022
A reliable android app that shows upcoming fixtures, updated league tables, and top goal scorers in a league

SwiftScore A football stats and livescore app built with Kotlin,MVVM architecture,Retrofit, Coroutines and Navigation Components Demo Screenshots API

Breens Mbaka 12 Jul 7, 2022
The home of the amigo-platform which serves as the main service for the amigo multimedia platform

amigo-platform This is the home of the amigo-platform which serves as the main service for the amigo multimedia platform. Authentication with JWT Toke

null 1 Nov 22, 2021
This app works as a simple replacement for SpongeAuth for those who want to use Discourse as the main SSO auth provider.

PowerNukkit Ore to Discourse Auth Gateway This app works as a simple replacement for SpongeAuth for those who want to use Discourse as the main SSO au

null 1 Apr 9, 2022
Candroid does things different. The Candroid app store is a library of APK client wrappers (F-Droid, APKPure, etc.) For the main Candroid app store, try visiting the Candroid Market.

Candroid App Store Candroid does things different. The Candroid app store is a library of APK client wrappers (F-Droid, APKPure, etc.) For the main Ca

Sean P. Myrick V19.1.7.2 4 Dec 22, 2022
Basic RestAPI to practice my skills working with Spring/Kotlin/Gradle

Dining Review API Dining Review API is a basic RestAPI roughly based on the requirements given in a Milestone project in the Building REST APIs with J

Jonas Kuhlo 0 Nov 18, 2021
This is a practice app. An app that you can find random recipes and choose the ones you like.

A food suggestion app like Tinder This is a practice app. In this app, you can find random recipes and choose the ones you like. This is main menu. Yo

Yunus Emre OCAK 4 May 25, 2022
Solutions to Hackerrank and CoderByte practice problems

Solutions to Hackerrank and CoderByte practice problems This repository contains solutions to CoderByte and Hackerrank practice problems with Kotlin.

Mert Toptas 2 Jul 5, 2022
PlaceAutoComplete - Practice Repository for placesearch using google places Api

PlaceAutoComplete Practice Repository for placesearch using google places Api Ap

Nayeem Shiddiki Abir 0 Jan 1, 2022
In this single activity app. i was trying to practice on ViewModel and Livedata

CalwithViewModel In this single activity app. i was trying to practice on ViewModel and Livedata Min Api Level : 19 Setup Requirements Android device

Tech_G 1 Feb 16, 2022
An library to help android developers working easly with activities and fragments (Kotlin version)

AFM An library to help android developer working easly with activities and fragments (Kotlin) Motivation Accelerate the process and abstract the logic

Massive Disaster 12 Oct 3, 2022
A pragmatic lightweight dependency injection framework for Kotlin developers.

A pragmatic lightweight dependency injection framework for Kotlin developers. Koin is a DSL, a light container and a pragmatic API

insert-koin.io 11 Dec 14, 2022