GithubHelp home page GithubHelp logo

plumpmath / quarantining-test-runner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from binarytweed/quarantining-test-runner

0.0 0.0 0.0 240 KB

JUnit Runner that loads specified classes in a separate ClassLoader, which can be handy when depending on third party frameworks which make use of static members.

License: MIT License

Java 100.00%

quarantining-test-runner's Introduction

quarantining-test-runner

Build Status

A JUnit test runner that loads the test class and optionally specified classes in a separate ClassLoader. This means that static members will effectively be reset between each test class, as new versions of those classes are loaded.

Maven dependency

<dependency>
  <groupId>com.binarytweed</groupId>
  <artifactId>quarantining-test-runner</artifactId>
  <version>0.0.3</version>
</dependency>

Check the latest version on Maven Central.

To use

import com.binarytweed.test.Quarantine;
import com.binarytweed.test.QuarantiningRunner;

@RunWith(QuarantiningRunner.class)
@Quarantine({"com.binarytweed", "com.example.ClassName"})
public class MyIsolatedTest {
...
  1. Annotate your test class with @RunWith(QuarantiningRunner.class).
  2. Use @Quarantine("com.example") to specify patterns which separately-loaded class names should start with.
  3. Optionally specify @DelegateRunningTo(SomeCustomRunner.class) to have QuarantiningRunner use another Runner implementation. By default it uses org.junit.runners.JUnit4 (which currently extends BlockJUnit4ClassRunner).

How it works

The test class and runner class are loaded using QuarantiningUrlClassLoader. When either of these two classes reference a class that hasn't yet been loaded, QuarantiningUrlClassLoader will be used to load the requested class.

It will delegate loading classes that do not match the patterns provided by @Quarantined to its parent ClassLoader; patterns that do match are loaded by itself. Because each test run uses a a distinct instance of QuarantiningUrlClassLoader, any classes it loads are distinct from any previous runs.

quarantining-test-runner's People

Contributors

binarytweeddeej avatar seanf avatar

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.