Skip to content

QuarkusTest: consider removing the test profile support for @Nested tests #45349

Open
@mkouba

Description

Currently, it is possible to specify a test profile for a @Nested test (inner class of a top-level test class). However, this may cause troubles if the enclosing test class defines a different test profile; i.e. the enclosing class should be tested against a different application build. Keep in mind that Quarkus always needs to obtain the instance of the enclosing test class from the CDI container.

More specifically, if a CDI bean Foo is only enabled in the profile FooProfile then it cannot be injected in the test class FooTest because it would cause unsatisfied dependency in the test class FooTest$FooNested:

@TestProfile(FooProfile.class) // -> enables Foo
public class FooTest {
   
    @Inject Foo foo; // this is legal and works fine when FooTest#test() is run

    void test() {
       // ...
    }

   @Nested
   @TestProfile(FooNestedProfile.class) // -> Foo is not enabled here
   class FooNested {
     
      void test() {
         // ...this test always fails because when the test app is built FooTest#foo results in an unsatisfied dependency
      } 
     
   }

}

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions