Skip to content

Commit

Permalink
[maven][doc-generator] Update the name of the tests to see the name a…
Browse files Browse the repository at this point in the history
…nd path of the tested page.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Mar 12, 2020
1 parent 9c0d554 commit 7e0e7ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Expand Up @@ -244,13 +244,15 @@ protected void internalExecute(File sourceFolder, File inputFile, File relativeI
}

// Do not change the "Test" postfix because it is used by Surefire for detecting test classes.
final String generalTestName = toTestName(inputFile) + "Test"; //$NON-NLS-1$
final String basicTestName = toTestName(inputFile);
final String generalTestName = basicTestName + "Test"; //$NON-NLS-1$

final ImportManager importManager = new ImportManager();
final TraceableTreeAppendable it = new TraceableTreeAppendable(importManager);

it.append("@").append(DisplayName.class).append("(\"")
.append(inputFile.getName()).append("\")").newLine();
final String displayName = toClassDisplayName(relativeInputFile, basicTestName, generalTestName);

it.append("@").append(DisplayName.class).append("(\"").append(displayName).append("\")").newLine();
it.append("public class ").append(generalTestName).append(" extends ")
.append(BASE_PACKAGE).append(".AbstractBaseTest").append(" {").increaseIndentation().newLine();

Expand Down Expand Up @@ -791,6 +793,11 @@ private static String toTestDisplayName(String name, int index, ValidationCompon
return MessageFormat.format(nm, index, component.getLinenoInSourceFile());
}

private static String toClassDisplayName(File inputFile, String basicTestName, String generalTestName) {
return MessageFormat.format(Messages.GenerateTestsMojo_12, inputFile.getName(), basicTestName, generalTestName,
inputFile.getParentFile().getPath());
}

private static String str(Object obj) {
if (obj == null) {
return ""; //$NON-NLS-1$
Expand Down
Expand Up @@ -56,6 +56,7 @@ public class Messages extends NLS {
public static String GenerateTestsMojo_9;
public static String GenerateTestsMojo_10;
public static String GenerateTestsMojo_11;
public static String GenerateTestsMojo_12;
public static String InitializeMojo_0;
public static String InitializeMojo_1;
public static String InitializeMojo_2;
Expand Down
Expand Up @@ -20,6 +20,7 @@ GenerateTestsMojo_8=Expected failure: {0} line: {1}
GenerateTestsMojo_9=Fact: {0} line: {1}
GenerateTestsMojo_10=Dynamic fact: {0} line: {1}
GenerateTestsMojo_11=Generating the testing resources
GenerateTestsMojo_12=Page {1} ({3})
InitializeMojo_0=Adding source folder: {0}
InitializeMojo_1=Source folder already defined: {0}
InitializeMojo_2=Adding test source folder: {0}
Expand Down

0 comments on commit 7e0e7ba

Please sign in to comment.