Skip to content

Influence invocation order for TestTemplate executions #1141

@sebersole

Description

@sebersole

When using TestTemplate, JUnit will perform executions grouped by the test method. For example, if I have a test class that defines 2 test methods (m1, m2) as TestTemplate and provide 2 invocation contexts (c1, c2) - JUnit will perform this in the following order:

    * m1:c1
    * m1:c2
    * m2:c1
    * m2:c2

But what I really need is:

    * m1:c1
    * m2:c1
    * m1:c2
    * m2:c2

My use case is that the invocation context describes a particular database schema layout. So c1 and c2 define the same schema, but slightly differently (one adds extra columns to a given table and defoines others). Given that JUnit wants to group these invocations by method (iterating the context within that) we are forced to recreate that schema before each invocation. Effectively this becomes:

    * create schema1 (c1) 
    * run m1
    * drop schema1
    * create schema2 (c2) 
    * run m2
    * drop schema2
    * create schema1 (c1)
    * run m1
    * drop schema1
    * create schema2 (c2) 
    * run m2
    * drop schema2

Obviously that works a lot better as:

    * create schema1 (c1) 
    * run m1
    * run m2
    * drop schema1
    * create schema2 (c2) 
    * run m1
    * run m2
    * drop schema2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions