Code Monkey home page Code Monkey logo

androidcrashdummy's Introduction

AndroidCrashDummy

Exceptions, logs, more playing about (@julianharty)

What?

This app is for testing exceptions and logging. It allows us to implement and test approaches to improving logging/testing.

Testing Logging

In this app, there is an instrumentation test called "clickLog100Button". This test clicks a UI button which triggers 100 log messages to be created. The test then looks for a specific final message (using RegExp) and passes/fails based on it's presence.

@Test
public void clickLog100Button() throws Exception {

    clearLog(); // Otherwise our logcat command could show previous test-runs etc.
    onView(withId(R.id.log100)).perform(click()); // UI Action / Trigger logs
    String log = getLogs(); // Get all logs in logcat buffer for this app (could have logs from parallel executions, not just the line above)

    Log.d("LogTest", "Output from log reading has length: [" + log.length() + "]");

    Pattern mPattern = Pattern.compile("Logging 100 messages took [0-9]+ Milliseconds");

    Matcher matcher = mPattern.matcher(log);
    if(!matcher.find()) {
        throw new Exception("Logging was not detected!");
    } else {
        Log.i("LogTest", "ClickLog100Button Passed");
    }
}

androidcrashdummy's People

Contributors

isnit0 avatar julianharty avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

commercetest

androidcrashdummy's Issues

LogTest fails to run, denied permission.

Revisiting this project after a year or so, I can't get the LogTest to run. Instead it's denied permission as the app does not have READ_LOGS permission (even though the permission was specified in the AndroidManifest.xml for the debug build).

I've spent about a day or so investigating where the issues are and finally decided it's worth writing this issue to keep track of the progress.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.