Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a watcher (JUnit 3) test rule (JUnit 4) for hanging test logging #774

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 2, 2023

  1. Add a watcher (JUnit 3) test rule (JUnit 4) for hanging test logging

    Tests may be (and actually are every now and then) hanging for different
    reasons, such as livelocks or deadlocks. A hanging test does not log
    anything on its own anymore, which makes it difficult to identify a
    hanging test and the reasons for that. To this end, it would be useful
    to have an additional entity that logs the state of all threads, i.e., a
    thread dump, when a test takes longer than a defined threshold.
    
    Since several tests need to run in the UI thread, the JUnit Timeout rule
    cannot be used, as it executes a test in a different thread that can
    even be terminated preemptively after a timeout. Instead, this change
    introduces a HangingTestRule that spawns a watcher thread that writes a
    thread dump whenever a test (that is run in the UI thread) takes more
    time than a defined timeout.
    In total, this change does the following:
    - Makes the thread dump logic currently placed in TestBarrier2 reusable
    in a central TestUtil
    - Adds a HangingTestWatcher that writes a thread dump if not stopped
    after a given timeout (compatible with JUnit 3)
    - Adds a HangingTestRule that wraps the HangingTestWatcher into a JUnit
    4 rule
    - Adds the HangingTestRule to the ResourceTest class to apply the
    logging to all subclasses that are executed with JUnit 4
    HeikoKlare committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    1dd26d0 View commit details
    Browse the repository at this point in the history