Junit ClassLoader per test runner

ClassLoader per Test runner for JUnit 4.12+ based on myfaces-test "TestPerClassLoaderRunner".

License

License

Apache License Version 2.0, January 2004
Categories

Categories

JUnit Unit Testing
GroupId

GroupId

org.bitstrings.test
ArtifactId

ArtifactId

junit-clptr
Last Version

Last Version

1.2.2
Release Date

Release Date

Type

Type

jar
Description

Description

Junit ClassLoader per test runner
ClassLoader per Test runner for JUnit 4.12+ based on myfaces-test "TestPerClassLoaderRunner".
Project Organization

Project Organization

bitstrings.org
Source Code Management

Source Code Management

https://github.com/bitstrings/junit-clptr

Download junit-clptr

How to add to project

<!-- https://jarcasting.com/artifacts/org.bitstrings.test/junit-clptr/ -->
<dependency>
    <groupId>org.bitstrings.test</groupId>
    <artifactId>junit-clptr</artifactId>
    <version>1.2.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.bitstrings.test/junit-clptr/
implementation 'org.bitstrings.test:junit-clptr:1.2.2'
// https://jarcasting.com/artifacts/org.bitstrings.test/junit-clptr/
implementation ("org.bitstrings.test:junit-clptr:1.2.2")
'org.bitstrings.test:junit-clptr:jar:1.2.2'
<dependency org="org.bitstrings.test" name="junit-clptr" rev="1.2.2">
  <artifact name="junit-clptr" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.bitstrings.test', module='junit-clptr', version='1.2.2')
)
libraryDependencies += "org.bitstrings.test" % "junit-clptr" % "1.2.2"
[org.bitstrings.test/junit-clptr "1.2.2"]

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status

junit-clptr

ClassLoader per Test runner for JUnit 4.12+ based on myfaces-test "TestPerClassLoaderRunner".

Each test method will run with its very own ClassLoader which can be very useful for a variety of use cases (testing classes with static fields for example).

Maven dependency

<dependency>
  <groupId>org.bitstrings.test</groupId>
  <artifactId>junit-clptr</artifactId>
  <version>1.2.2</version>
</dependency>

Usage

import org.bitstrings.test.junit.runner.ClassLoaderPerTestRunner;

@RunWith( ClassLoaderPerTestRunner.class )
public class Test
{
  ...
}

Exclude classes using @ClptrExclude annotation

You can exclude a package or a specific class.

@RunWith( ClassLoaderPerTestRunner.class )
@ClptrExclude( "mockit." )
public class Test
{
    ...
}
@RunWith( ClassLoaderPerTestRunner.class )
@ClptrExclude( { "mockit.", "org.somethings.MyClass" } )
public class Test
{
    ...
}

You may use @ClptrExclude on classes and methods.

Globally exclude classes from isolation using file

Use the default file clptr-excludes.properties to add excluded packages or classes from isolation.

The file should be on the classpath.

You can override the excludes file location using the system property org.bitstrings.test.junit.runner.TestClassLoader.excludes.

org.bitstrings.test.junit.runner.TestClassLoader.excludes=com/company/res/clptr-excludes.properties

The file is simply a list of packages and classes (see @ClptrExclude):

jmockit.
org.apache.
com.company.test.TestClass

What's new

  • @ClptrExclude annotation;
  • Fix for "@Rule" annotated field and method;
  • Threadsafe (Hopeful...);
  • Support excludes.

Versions

Version
1.2.2
1.2.1
1.2
1.1
1.0