Skip to content

Thread context classloader should be reset after each test #1799

@bacer-esteco

Description

@bacer-esteco

Overview

Whenever a test case sets the thread context ClassLoader, the test runner thread keeps using that ClassLoader for the following tests. This causes failures when combined with Mockito and mocks of package private classes/interfaces.

Expected Behavior

When the thread is reused to run another test, the context ClassLoader should be reset to the original one.

Steps to Reproduce

To reproduce the problem I created this example repo: https://github.com/bacer-esteco/junit5-bug-report.

Just run the 'test' task.

This problem is reproducible using both Jupiter and Vintage (tried on version 5.4.0), launching the test both from Gradle 5.2.1 and IntelliJ IDEA 2018.3 (and previous).

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions