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

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

Closed
wind57 opened this issue Oct 5, 2024 · 2 comments

Comments

@wind57
Copy link

wind57 commented Oct 5, 2024

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.

@sbrannen sbrannen changed the title Incorrect order on print statements when using @Suite/@BeforeSuite Incorrect order of print statements when using @Suite and @BeforeSuite Oct 5, 2024
@sbrannen
Copy link
Member

sbrannen commented Oct 5, 2024

Hi @wind57,

Congratulations on raising your first issue for JUnit 5! 👍

When I run your example in Eclipse IDE, I get the following output on the console.

before suite
testing : 42
after suite

And since you also see testing : 42 instead of testing : 0 in IntelliJ, I assume that the different console output you see is perhaps related to how IntelliJ handles/redirects System.out.

In light of that, I am closing this issue, but feel free to raise an issue directly in the IntelliJ IDEA issue tracker.

Cheers,

Sam

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2024
Copy link

github-actions bot commented Oct 5, 2024

Please assign a status label to this issue.

@github-actions github-actions bot reopened this Oct 5, 2024
@sbrannen sbrannen changed the title Incorrect order of print statements when using @Suite and @BeforeSuite Incorrect order of print statements when using @Suite and @BeforeSuite with IntelliJ IDEA Oct 5, 2024
@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2024
@sbrannen sbrannen self-assigned this Nov 27, 2024
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

2 participants