JUnit Dynamic Suite

Dynamic Suite Runner for JUnit 4

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.github.cschoell
ArtifactId

ArtifactId

junit-dynamicsuite
Last Version

Last Version

0.2.5
Release Date

Release Date

Type

Type

jar
Description

Description

JUnit Dynamic Suite
Dynamic Suite Runner for JUnit 4
Project URL

Project URL

https://github.com/cschoell/Junit-DynamicSuite
Source Code Management

Source Code Management

https://github.com/cschoell/Junit-DynamicSuite

Download junit-dynamicsuite

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.apache.commons : commons-lang3 jar 3.3.2

test (2)

Group / Artifact Type Version
commons-io : commons-io jar 2.4
org.mockito : mockito-all jar 1.9.5

Project Modules

There are no modules declared in this project.

JUnit DynamicSuite

The JUnit DynamicSuite is a library used to create a dynamic Suite of JUnit Tests from a directory. The Unit Tests can be filtered dynamically by annotating the Suite with a filter.

Dependencies

Usage

To get your started just annotate a class with

@RunWith(DynamicSuite.class)
@Filter(DefaultFilter.class)
@Directory

This will run all Tests ending with “Test” in the directory

target/test-classes

which is specified as default in the Directory Annotation.

Instead of using @Directory you might use as well

@ClassPath(includeJars = true)

which scans the ClassPath for test classes. The Parameter includeJars allows you to control wether to scan the jars on the classpath (default false - only directories).

To create a custom filter you may either implement the interface TestClassFilter or extend the DefaultFilter.

Other Options

Available with Version 0.2.5:

You may use the Annotation @Directories to search for test classes in multiple directories.

@Directories({"bin", "target/classes"})
@Directories({"src/test/java", "src/test/generated"})

Available with Version 0.2.3:

You may use the Annotation @Sort to sort the tests by TestName or Randomize them.

@Sort(SortBy.TESTNAME) //sort by Name of Test
@Sort(SortBy.RANDOM) //run Tests in a random order
@Sort(value = SortBy.CUSTOM, customSort=<<class implementing TestSort>>.class)

Example

You can let the dynamic suite directly implement the TestClassFilter interface as shown below.

@RunWith(DynamicSuite.class)
@Filter(IntegrationSuite.class)
@Directory("test/out")
@Sort(SortBy.RANDOM)
public class IntegrationSuite implements TestClassFilter {

    @Override
    public boolean include(String className) {
        return className.endsWith("ITCase");
    }

    @Override
    public boolean include(Class cls) {
        return cls.getAnnotation(Ignore.class) == null;
    }
}

Installation

Either include the library directly by downloading it here or include it in Maven (from Maven Central Repository):

<dependency>
    <groupId>com.github.cschoell</groupId>
    <artifactId>junit-dynamicsuite</artifactId>
    <version>0.2.5</version>
    <scope>test</scope>
</dependency>

Copyright © 2013 Christof Schoell

The files in this archive are released under the Apache 2.0 license.

You may obtain a copy of this license under www.apache.org/licenses/LICENSE-2.0

Versions

Version
0.2.5
0.2.3
0.2.2
0.2.1
0.2.0