Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Influence invocation order for TestTemplate executions #1141

Closed
sebersole opened this issue Nov 3, 2017 · 4 comments
Closed

Influence invocation order for TestTemplate executions #1141

sebersole opened this issue Nov 3, 2017 · 4 comments

Comments

@sebersole
Copy link

sebersole commented Nov 3, 2017

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
@marcphilipp
Copy link
Member

Makes sense! Sounds like #871, right?

@sbrannen
Copy link
Member

sbrannen commented Nov 3, 2017

Actually, yes... I think this is a duplicate of #871.

@sebersole, do you agree?

@sebersole
Copy link
Author

Maybe. To be honest I am not following most of that discussion :) But looking at his "expected order" of execution, that seems to match

@sbrannen
Copy link
Member

sbrannen commented Nov 3, 2017

OK. Closing this in favor of #871.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants