Skip to content

Commit

Permalink
Option to not report package names in the report. issue #248
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiag committed Nov 9, 2020
1 parent c87d45a commit 475dfe0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public enum DifidoOptions implements ConfigOptions {
// @formatter:off
REPORTER_CLASSES("reporter.classes", LocalDifidoReporter.class.getName() +";" + RemoteDifidoReporter.class.getName() +";" +ConsoleReporter.class.getName()),
MIN_TIME_BETWEEN_WRITES("min.time.between.writes","100"),
LOG_LEVEL("log.level","INFO");
LOG_LEVEL("log.level","INFO"),
REPORT_PACKAGE_NAMES("report.package.names","true");
// @formatter:on

private String property;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ public abstract class AbstractDifidoReporter implements Reporter {

private boolean inTeardown;

private boolean reportPackageNames;

public AbstractDifidoReporter() {
config = new DifidoConfig();
bufferedElements = new ArrayList<ReportElement>();
bufferedTestProperties = new HashMap<>();
bufferedRunProperties = new HashMap<>();
reportPackageNames = config.getPropertyAsBoolean(DifidoOptions.REPORT_PACKAGE_NAMES);

}

Expand Down Expand Up @@ -121,7 +124,7 @@ private void updateIndex() {
* executed on, will append the results to the last machine and will not
* create a new one.
*
* @param context
* @param host
*
*/
private void addMachineToExecution(String host) {
Expand Down Expand Up @@ -172,9 +175,19 @@ private static String getMachineName() {

@Override
public void onTestStart(ITestResult result) {
if (!result.getTestClass().getName().equals(testClassName)) {
testClassName = result.getTestClass().getName();
startClassScenario(result);
if (!reportPackageNames) {
// Getting only the class name without the package (issue #248)
final String className = result.getTestClass().getName().substring(result.getTestClass().getName().lastIndexOf(".") + 1);
if (!className.equals(testClassName)) {
testClassName = className;
startClassScenario(result);
}
} else {
// The package names will be reported
if (!result.getTestClass().getName().equals(testClassName)) {
testClassName = result.getTestClass().getName();
startClassScenario(result);
}
}
String testName = result.getName();
List<String> testParameters = getTestParameters(result);
Expand Down

0 comments on commit 475dfe0

Please sign in to comment.