-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: main
Are you sure you want to change the base?
Conversation
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
ConsoleLauncher
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. |
I prefer staying in this PR. The primary goal is to output The extra changes requested in #3397:
should come later as it would be easier once we have one successful example. |
There was a problem hiding this 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 thediff info
spreadingdiff info
to all the Junit API outputshould 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.
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
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.).
There was a problem hiding this comment.
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
, orDetails.TREE
is used. We should be able to extract the diff-printing code to a separate class and call it fromMutableTestExecutionSummary
, and the other listeners (FlatPrintingListener
etc.).
The solutions I can think of:
- add diff output function to
junit-platform-commons...util.StringUtils
- Use the diff output function in
FlatPrintingListener
,TreePrintingListener
,VerboseTreePrintingListener
andMutableTestExecutionSummary
I will start to work on it if the solution looks right for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add diff output function to
junit-platform-commons...util.StringUtils
I think it should stay in junit-platform-console. Please create a separate DiffPrinter
class or similar.
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:
junit-platform-console/.../tasks/ConsoleTestExecutor.java
(output of console)libs.versions.toml
andjunit-platform-console.gradle.kts
ofjunit-platform-console
release-notes-5.12.0-M1.adoc
Tasks that need to finish
junit-platform-console/.../module-info.java
(causing testing failure because the auto test cases can not find the diff package)ConsoleTestExecutorTests.java
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotationscontinue from #3397
Issue: #3139