forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Add diffPrinter class 2. replace diff in consoleTestExecutor with diffPrinter - will be deleted evetually 3. mark the location of adding diff in flatPrinter and verboseTreePrinter. Issue: junit-team#3139
- Loading branch information
Showing
4 changed files
with
38 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
junit-platform-console/src/main/java/org/junit/platform/console/tasks/DiffPrinter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.platform.console.tasks; | ||
|
||
import java.io.PrintWriter; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import com.github.difflib.text.DiffRow; | ||
import com.github.difflib.text.DiffRowGenerator; | ||
|
||
/** | ||
* class provide access to printDiff function | ||
*/ | ||
class DiffPrinter { | ||
//print the difference of two print to out | ||
static void printDiff(PrintWriter out, String expected, String actual) { | ||
DiffRowGenerator generator = DiffRowGenerator.create().showInlineDiffs(true).inlineDiffByWord(true).oldTag( | ||
f -> "~").newTag(f -> "**").build(); | ||
List<DiffRow> rows = generator.generateDiffRows(Arrays.asList(expected), Arrays.asList(actual)); | ||
out.printf("\nPlease put the diff result below into a online markdown editor to see markdown effect: \n"); | ||
for (DiffRow row : rows) { | ||
out.printf(" | %s | %s | \n", row.getOldLine(), row.getNewLine()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters