Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Build Status Test Coverage Test Coverage


The sweet junit runner allows to dynamically load test classes into junit Suites.

The problem to solve

The maintenance of integration tests is a difficult and time consuming process.

In a Spring managed environment for example, each integration test starts the spring container before the test execution and destroys it when the test is finished. This is a very time consuming process, especially if there are dozens of test cases.

To solve the problem you can group your tests into junit Suites like this:


public class JunitTestSuite {

As you can see, this solution requires you to hard code the test classes in the JunitTestSuite in order to execute them. If one writes another test and forgets to add it to the SuiteClasses list, the test will not be executed.


Using annotations

The sweet-junit-runner allows to dynamically load test classes annotated with @IntegrationTest or @SuiteTest into a JUnit Suite as follows:

public class IntegrationTestToLoadTest {

    public void testMe() {
        System.out.println("I was here!");


public class UnitTestToLoadTest {

    public void testMe() {
        System.out.println("I was here!");

public class IntegrationTestSuite {

Note that you have to provide a SuiteConfiguration to tell the runner where to search for the classes that have to be loaded:

In the previous example the

  • org.codelamb.sweet.TestJunit1 - would be loaded

  • org.codelamb.sweet.sample.TestJunit2 - would be loaded

  • org.codelamb.TestJunit3 - would NOT be loaded

This way one can assign different test classes to different junit Suites.

Using a pattern

If you do not want to annotate all your test-classes its possible to use a pattern which will load all classes that match this pattern.

@SuiteConfiguration(value = "org.codelamb.sweet", containsFilter = "Test")
public class IntegrationTestSuite {

In the previous example the

  • org.codelamb.sweet.TestJunit1 - would be loaded (because of its annotated)

  • org.codelamb.sweet.sample.TestJunit2 - would be loaded (because of its annotated)

  • org.codelamb.TestJunit3 - would be be loaded (because it matches containsFilter)

Maven integration

The maven-surefire-plugin allows to execute Suites. For example:


Future ideas

Extended configuration

Allow loading test classes based on naming pattern as an alternative for @IntegrationTest annotation


Add Preconditions to simplify the maintenance of integration test

  • integration test can be linked to a precondition

  • preconditions will be checked before the test are executed

  • the integration test will not be executed when the precondition test fails

Use case

20 out of 50 Integration tests depend on a Database connection. If the Database is down, the 20 Tests will not be executed. The precondition test will be failing with a proper explanation.


Automatically loads Integration Tests into Junit Suite. Build for Integration Test execution performance and maintenance.








No packages published

Contributors 4