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

[SPARK-48386][TESTS] Replace JVM assert with JUnit Assert in tests #46698

Closed
wants to merge 6 commits into from

Conversation

panbingkun
Copy link
Contributor

What changes were proposed in this pull request?

The pr aims to replace JVM assert with JUnit Assert in tests.

Why are the changes needed?

assert() statements do not produce as useful errors when they fail, and, if they were somehow disabled, would fail to test anything.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

  • Manually test.
  • Pass GA.

Was this patch authored or co-authored using generative AI tooling?

No.

@panbingkun
Copy link
Contributor Author

This PR reference:
1febd37
#37772

@panbingkun
Copy link
Contributor Author

@LuciferYang
Copy link
Contributor

I think it is necessary to create a jira

@panbingkun
Copy link
Contributor Author

I think it is necessary to create a jira

Done.

@panbingkun panbingkun changed the title [MINOR][TESTS] Replace JVM assert with JUnit Assert in tests [SPARK-48386][TESTS] Replace JVM assert with JUnit Assert in tests May 22, 2024
Copy link
Contributor

@LuciferYang LuciferYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM (pending tests)

@@ -127,8 +128,8 @@ public void testBasicLoggerWithException() {
Pair.of(Level.DEBUG, debugFn),
Pair.of(Level.TRACE, traceFn)).forEach(pair -> {
try {
assert (captureLogOutput(pair.getRight()).matches(
expectedPatternForBasicMsgWithException(pair.getLeft())));
Assertions.assertTrue(captureLogOutput(pair.getRight()).matches(
Copy link
Member

@dongjoon-hyun dongjoon-hyun May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we import assertTrue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -78,9 +80,9 @@ public Predicate[] pushPredicates(Predicate[] predicates) {

Predicate[] unsupported = Arrays.stream(predicates).filter(f -> {
if (f.name().equals(">")) {
assert(f.children()[0] instanceof FieldReference);
Assertions.assertInstanceOf(FieldReference.class, f.children()[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto. Shall we import assertInstanceOf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM.

@dongjoon-hyun
Copy link
Member

Thank you for updating, @panbingkun .

@LuciferYang
Copy link
Contributor

Merged into master for Spark 4.0. Thanks @panbingkun and @dongjoon-hyun ~

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

Successfully merging this pull request may close these issues.

3 participants