Skip to content

Multiple containers for @Nested classes #312

@nlisker

Description

@nlisker

When testing with @Nested classes, Weld initiates a container for each nested level. Could be related to #288, though this is regardless of @TestInstance(Lifecycle.PER_CLASS).
For example:

@EnableAutoWeld
public class WeldTest {

	@Nested
	class A {

		@Test
		void a() {
			System.out.println("a");
		}

		@Nested
		class A2 {

			@Test
			void a() {
				System.out.println("a");
			}
		}
	}

	@Nested
	class B {

		@Test
		void a() {
			System.out.println("a");
		}
	}
}

will start 3 containers: for WedTest, A and A2. Removing B does nothing. This causes a warning in more complicated cases:

org.jboss.weld.environment.se.WeldSEProvider getCDI
INFO: WELD-ENV-002006: Multiple containers running - CDI.current() may not work properly

Is this the correct behavior? I'd assume the same container can be used here.

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