Skip to content

Add support for test pre-processors #766

@vasiliygagin

Description

@vasiliygagin

Currently in order to apply any pre-processing, common approach is to override Runner (or subclass of it).
For example to add Spring Framework injection I'd use:

@RunWith(SpringJUnit4ClassRunner.class)

And for Unitils support I'd use:

@RunWith(UnitilsJUnit4TestClassRunner.class).

But what happens when you need support for both?
Unitils actually is trying to solve this problem by supporting some (but not all) of Spring annotations.

It would benefit Java world if JUnit would support something like this:

@ProcessWith({SpringJUnitTestProcessor.class, UnitilsJunitTestProcessor.class})

In this case default BlockJUnit4ClassRunner will be used but listed processors will take care of their own responsibilities and would not have to know about each other.
Each of the processors would have to implement so common interface with a method like this:

public void prepareTest(Object testInstance, Method testMethod).

If there is an interest in this features, I'd like to contribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions