Code Monkey home page Code Monkey logo

Comments (5)

overheadhunter avatar overheadhunter commented on August 16, 2024

To add some context:

JUnit 5 adds support for an arbitrary amount of @Nested tests. Currently, the Flyway migration scripts will only run for direct members of the annotated class:

@FlywayTest(...)
class Test {

    @Test
    public void test1() { ... } // ✔︎

    @Nested
    public class Nested1 {

        @Test
        public void test2() { ... } // ✘

    }

    @Nested
    @FlywayTest(...)
    public class Nested2 {

        @Test
        public void test3() { ... } // ✔︎

    }

}

I would expect nested test classes to inherit the behaviour from their parent. That said, it should be possible to overwrite behaviour in nested classes (i.e. setting clean = false for nested class that has an @Ordered sequence of tests).

There may be one difficult edge case, though: If a parent class is annotated with clean = false, all descendant tests are inherently stateful. However, if a @Nested class now decides to use clean = true, it resets the parent's state. In other words: We either need a mechanism to make a copy of the parent's state ("clone the database") or need to document that behaviour is unspecified in this scenario.

Vice versa (parent cleans, nested doesn't) shouldn't be a problem, though.

from flyway-junit5-extensions.

radcortez avatar radcortez commented on August 16, 2024

Thanks. I'll have a look.

from flyway-junit5-extensions.

radcortez avatar radcortez commented on August 16, 2024

@overheadhunter any chance for you to try out #147?

The @FlywayTest behaviour is always a merge of all metadata across the hierarchy (or enclosing class).

For instance, if a parent class is annotated with clean = false, all nested classes also inherit the same behaviour. If a nested class overrides clean = true, it applies only in the context of that nested class.

from flyway-junit5-extensions.

overheadhunter avatar overheadhunter commented on August 16, 2024

On first glance that seems to work. 🙌

However, Quarkus is giving me a hard time testing multiple levels of nested tests. So I can not really verify this case.

from flyway-junit5-extensions.

radcortez avatar radcortez commented on August 16, 2024

Ok, thanks. I'll do a release as is, and then we will try to figure out on the Quarkus side.

from flyway-junit5-extensions.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.