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

Output diff of expected and actual values in ConsoleLauncher #4017

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

XJ114514
Copy link

@XJ114514 XJ114514 commented Sep 23, 2024

Overview

Current PR can successfully build and generate junit-platform-console-standalone-1.12.0-SNAPSHOT.jar containing diff outputs for two different Strings to the console.

Changes made in this draft PR:

  • add diff function to junit-platform-console/.../tasks/ConsoleTestExecutor.java (output of console)
  • add dependency to libs.versions.toml and junit-platform-console.gradle.kts of junit-platform-console
  • add changed that will be made to release-notes-5.12.0-M1.adoc

Tasks that need to finish

  • add package documentation to junit-platform-console/.../module-info.java (causing testing failure because the auto test cases can not find the diff package)
  • add auto test cases for diff output in ConsoleTestExecutorTests.java

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done


continue from #3397
Issue: #3139

XuJ321 and others added 13 commits August 31, 2024 18:25
Tasks completed:
1. Locate ConsoleLauncher output
2. Check if actual and expected of AssertionFailedError are both type of CharSequence
To do list:
1. Add diff function dependency
2. Using diff to generate the output desired

Issue: junit-team#3139
Tasks completed:
1. Locate ConsoleLauncher output
2. Check if actual and expected of AssertionFailedError are both type of CharSequence
3. Add diff function dependency
4. Using diff to generate the output desired

Issue: junit-team#3139
delete one line of extra code
Fixed different profile issue.

Tasks completed:
1. Locate ConsoleLauncher output
2. Check if actual and expected of AssertionFailedError are both type of CharSequence
3. Add diff function dependency
4. Using diff to generate the output desired

ToDo:
1.Automatic test case for diff output

Issue: junit-team#3139
Add external diff module  to module documentation
For unknown reason, the test cases can not find the external module while the gradle can build normally.

Issue: junit-team#3139
@marcphilipp
Copy link
Member

@XJ114514 Could you please change this PR to continue where #3397 left off? We can then tackle the problems that remain one by one.

@marcphilipp marcphilipp marked this pull request as draft September 23, 2024 13:30
@sbrannen sbrannen changed the title Issue: junit-team#3139 Draft PR Output diff of expected and actual values in ConsoleLauncher Sep 23, 2024
@XJ114514
Copy link
Author

@XJ114514 Could you please change this PR to continue where #3397 left off? We can then tackle the problems that remain one by one.

I apologize for the trouble. But you already superseded and closed #3397. Is there anything I need to do?

@marcphilipp
Copy link
Member

I closed it because the original author didn't respond anymore. But if you're interested you could create a new branch in your repo based on their work and make the changes that were requested in #3397. Please let me know whether you want to proceed that way.

@XJ114514
Copy link
Author

I prefer staying in this PR. The primary goal is to output diff info in the console, create test cases, and successfully merge them.

The extra changes requested in #3397:

Shadowing the original external function
Using theme to highlight the diff info
spreading diff info to all the Junit API output

should come later as it would be easier once we have one successful example.

Copy link
Member

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

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

The extra changes requested in #3397:

Shadowing the original external function
Using theme to highlight the diff info
spreading diff info to all the Junit API output

should come later as it would be easier once we have one successful example.

We usually only merge complete PRs that leave main ready to be released. But I can help with the shadowing.

gradle/libs.versions.toml Outdated Show resolved Hide resolved
@@ -180,11 +186,39 @@ private Optional<TestExecutionListener> createXmlWritingListener(PrintWriter out
private void printSummary(TestExecutionSummary summary, PrintWriter out) {
// Otherwise the failures have already been printed in detail
if (EnumSet.of(Details.NONE, Details.SUMMARY, Details.TREE).contains(outputOptions.getDetails())) {
//adding diff code here
Copy link
Member

Choose a reason for hiding this comment

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

This should be done in place where we print the exceptions (as it is in #3397). Otherwise, it would be difficult to find the test that belongs to the diff in case of multiple failing tests.

Copy link
Author

Choose a reason for hiding this comment

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

image
image

Which part do you wish to change? The first print happens in DefaultLaucher and the second happens in MutableTestExecutionSummary. Both are in junit-platform-laucher module. Changes will affect all Junit API output I believe?
I can try to work on it over the weekend if you wish.
At the same time, can you help to find why the package documentation test case fails (Test cases can not find diff package once I add it to the module-info.java for documentation)

Copy link
Member

Choose a reason for hiding this comment

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

We also need to make sure that the diff is printed if a details mode other than Details.NONE, Details.SUMMARY, or Details.TREE is used. We should be able to extract the diff-printing code to a separate class and call it from MutableTestExecutionSummary, and the other listeners (FlatPrintingListener etc.).

Copy link
Author

Choose a reason for hiding this comment

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

We also need to make sure that the diff is printed if a details mode other than Details.NONE, Details.SUMMARY, or Details.TREE is used. We should be able to extract the diff-printing code to a separate class and call it from MutableTestExecutionSummary, and the other listeners (FlatPrintingListener etc.).

TBH, I do not know what you meant by the "details mode." All I did so far was dive into the code, find the corresponding output location of the console, and modify it. Is there a Javadoc or class diagram or something similar I can use to learn how the Junit5 handles output?

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.

ConsoleLauncher should output diff of expected and actual String values
4 participants