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
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
Learn about your favorite Marvel characters, super heroes, villains and watch videos from official Marvel youtube channel.

Marvel Super Heroes Android App ?? Learn about your favorite Marvel characters, super heroes, villains and watch videos from official Marvel youtube c

Lucas Cabral 5 May 24, 2022
Kata to practice Clean Architecture & MVI by building TodoList Application

Mvi Todo Kata Application Features TODO specification Title Description Due Date Priority Supported Operations Create a new TODO Remove a TODO Select

seungmin shin 0 Nov 3, 2021
MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK

MvvmKotlinJetpackCompose Why do we need an architecture even when you can make an app without it? let's say you created a project without any architec

Sayyed Rizwan 46 Nov 29, 2022
Solutions to Codeforces' Kotlin Heroes Contests

kotlin-heroes Solutions to Codeforces' Kotlin Heroes Contests Practice Rounds Contest Problems Solutions Practice-1 Link NA Practice-2 Link Link Pract

Yashvardhan Baid 2 Oct 4, 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
Registration validation testing, Room database testing using JUnit4

Notes app Registration details validation testing, Room database testing using JUnit4 ✨ Screenshots Authors Tridev Deka - LinkedIn - Tridev Deka MIT L

Tridev Deka 0 Mar 30, 2022
Transport Tycoon Kata

Transport Tycoon Kata This is a kata proposed by SoftwarePark. You can find the original one here I modified some parts of it, to make it different, m

Albert Casanovas 0 Aug 30, 2022
Cody Engel 2 Apr 20, 2022
A reliable android app that shows upcoming fixtures, updated league tables, and top goal scorers in a Premier League and French Ligue 1

RapidScore Screenshots Table of Contents Description Dependencies API Reference Lessons Learnt Contributing Roadmap Google Playstore License Author In

Breens Mbaka 12 Jul 7, 2022
Proyect with the goal to show my skills in android

ChipperMovie Es una aplicación de peliculas y sus detalles filtrados por categorias para demostrar el uso de mis habilidaedes en desarrollo movil. Ace

null 0 Nov 10, 2021
Paimondex App is an Android App that contains super mini wiki for playable characters from Genshin Impact, where you can favorite to save the character

Paimondex App is an Android App that contains super mini wiki for playable characters from Genshin Impact, where you can favorite to save the character. This could also show you the description of the each character with their talents and constellations.

Ervin Suriandi 1 Apr 13, 2022
A lightweight super-fast wireless file sharing application built on WiFi Peer-to-Peer technology.

ZipBolt ZipBolt is a file-sharing platform that allows digital devices to share files at incredible speeds using WiFi Peer-to-Peer technology. ZipBolt

Prosper Ekwerike 9 Sep 22, 2022
The goal of this assignment is to implement GameOfFifteen

Game of Fifteen Demo The board for the game of Fifteen is filled randomly with numbers from 1 to 15 and one empty space. You can move the neighboring

Josue Lubaki 0 Dec 6, 2021
CutableTextView - the super lightweight library that helps to you cut long text. ✂️

An easy to use CutableTextView when you need to cut a long text. ✂️ ✂️ ✂️ Gradle dependencies { implementation 'com.github.devit951:cutabletextvie

Ildarov 2 Aug 29, 2019
GOD - Goal of the day is the notes app which tracks your daily tasks, most important tasks & monthly goals

GOD - Goal of the day GOD - Goals of the day Problem Statement: People always face problems in finding their goals and keeping track over a period. Th

Shubham Jitiya 1 Jan 16, 2022
A console-based productivity app involving both To-Do Lists and Goal tracking

This is a console-based productivity app involving both To-Do Lists and Goal tracking. It allows users to create To-Dos, check them off, and filter the display between complete/incomplete items

Joel Jossie 3 Dec 25, 2022