Skip to content

lucoodevcourse/stopwatch-android-java

 
 

Repository files navigation

Background

The goal of this project is to convert a simple Java stopwatch to an Android application. The original java code can be found here.

Learning Objectives

Modeling

  • Modeling state-dependent behavior with state machine diagrams (see also here)
  • Distinguishing between view states and (behavioral) model states

Semantics

  • Event-driven/asynchronous program execution
  • User-triggered input events
  • Internal events from background timers
  • Concurrency issues: single-thread rule of accessing/updating the view in the GUI thread

Architecture and Design

  • Key architectural issues and patterns
    • Simple dependency injection (DI)
    • Model-view-adapter (MVA) architectural pattern
    • Mapping MVA to Android
    • Difference between MVA and model-view-controller (MVC)
    • Distinguishing among dumb, reactive, and autonomous model components
  • Key design patterns
    • Implementing event-driven behavior using the Observer pattern
    • Implementing state-dependent behavior using the State pattern
    • Command pattern for representing tasks as objects
    • Façade pattern for hiding complexity in the model from the adapter
  • Relevant class-level design principles
    • Dependency Inversion Principle (DIP)
    • Single Responsibility Principle (SRP)
    • Interface Segregation Principle (ISP)
  • Package-level architecture and relevant principles
    • Dependency graph (see also here)
    • Stable Dependencies Principle (SDP)
    • Acyclic Dependencies Principle (ADP)
  • Architectural journey

Testing

  • Different types of testing
    • Component-level unit testing
    • System testing
    • Instrumentation testing
  • Mock-based testing
  • Testcase Superclass pattern (uses Template Method pattern)
  • Test coverage

Setting up the Environment

Check out the project using Android Studio. This creates the local.properties file with the required line

sdk.dir=<root folder of Android Studio's Android SDK installation>

Running the Application

In Android Studio: Run > Run app

Running the Tests

Unit tests including out-of-emulator system tests using Robolectric

In Android Studio, use Tools > SDK Manager to install Android 6.0 (API level 23) for the Robolectric tests to work (skip this step if API level 23 is already installed). Then, in the Android view, right-click on edu.luc.etl.cs313...test (test) and choose Run 'Tests in 'test''.

You can also use Gradle:

$ ./gradlew testDebug # leave out the "./" on the Windows command line

You can view the resulting test reports in HTML by opening this file in your browser:

app/build/reports/tests/testDebugUnitTest/index.html

Unit test code coverage

In Gradle:

$ ./gradlew jacocoTestDebugUnitTestReport # leave out "./" on the Windows command line

You can view the resulting test reports in HTML by opening this file in your browser:

app/build/reports/jacoco/jacocoTestDebugUnitTestReport/html/index.html

Android instrumentation tests (in-emulator/device system tests)

In Android Studio:

  • In the Android view, right-click on edu.luc.etl.cs313...android (androidTest), then choose Run 'Tests in 'edu.luc.et...'

You can also use Gradle:

$ ./gradlew connectedDebugAndroidTest # leave out "./" on the Windows command line

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%