Skip to content

Incorrect order of print statements when using @Suite and @BeforeSuite with IntelliJ IDEA #4047

@wind57

Description

@wind57

I'm using junit-bom:

<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.junit</groupId>
				<artifactId>junit-bom</artifactId>
				<version>5.11.1</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
</dependencyManagement>

And I have two simple classes:

@Suite
@SelectClasses(TestClass.class)
public class MySuite {

	public static int x = 0;

	@BeforeSuite
	static void beforeSuite() {
		x = 42;
		System.out.println("before suite");
	}

	@AfterSuite
	static void afterSuite() {
		System.out.println("after suite");
	}

}

and

public class TestClass {

	@Test
	void test() {
		System.out.println("testing : " + MySuite.x);
	}

}

If run MySuite from IntelliJ (latest version available: Build #IU-241.19072.14, built on August 8, 2024), I get such an output:

testing : 42
before suite
after suite

While logically everything is correct, the order of the output is not: before suite should come before testing: 42.

The interesting part is that if I run the package where this MySuite resides, the output is now in the correct order.

Is this expected?

Thank you.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions