Skip to content

kimble/junit-test-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JUnit test factory runner

Download Build Status Coverage Status

Simple JUnit runner allowing you to dynamically generate tests with human readable names. This can be pretty convenient for adding customer generated test data into your test suites.

Btw, as far as I can tell, doing these things will be easier with JUnit 5.

Teaser

package com.github.kimble;

import com.github.kimble.FactoryRunner;

@RunWith(FactoryRunner.class)
public class TestFactoryRunnerTest implements FactoryRunner.Producer  {

    @Override
    public void produceTests(FactoryRunner.TestConsumer tc) throws Throwable {
        for (int i=0; i<10; i++) {
            final int number = i;
            final String name = String.format("Test %d", number);

            tc.accept(name, () -> {
                System.out.println("This is test #" + number);
            });
        }
    }
}

Gradle test report

Dynamically generated tests shows up as expected in html reports generated by Gradle.

Gradle test report

Intellij test runner

The same is true for Intellij, although you will not be able to re-run / debug a single test as you're used to.

Intellij test runner

About

JUnit test runner for dynamically generated tests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages