All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.shaft.tools.io.internal.CheckpointCounter Maven / Gradle / Ivy

Go to download

SHAFT is a unified test automation engine. Powered by best-in-class frameworks, SHAFT provides a wizard-like syntax to drive your automation efficiently, maximize your ROI, and minimize your learning curve. Stop reinventing the wheel. Upgrade now!

There is a newer version: 8.2.20240402
Show newest version
package com.shaft.tools.io.internal;

import com.shaft.tools.internal.support.HTMLHelper;

import java.util.ArrayList;
import java.util.HashMap;

public class CheckpointCounter {
    private static final HashMap> checkpoints = new HashMap<>();
    private static int passedCheckpoints = 0;
    private static int failedCheckpoints = 0;

    public static void increment(CheckpointType type, String message, CheckpointStatus status) {
        ArrayList entry = new ArrayList<>();
        entry.add(type.toString());
        entry.add(message);
        entry.add(status.toString());
        checkpoints.put(checkpoints.size() + 1, entry);

        if (status == CheckpointStatus.PASS) {
            passedCheckpoints++;
        } else {
            failedCheckpoints++;
        }
    }

    public static void attach() {
        StringBuilder detailsBuilder = new StringBuilder();
        checkpoints.forEach((key, value) -> detailsBuilder.append(String.format(HTMLHelper.CHECKPOINT_DETAILS_FORMAT.getValue(), key, value.get(0), value.get(1), value.get(2))));

        ReportManagerHelper.attach("HTML",
                "Checkpoints Report",
                HTMLHelper.CHECKPOINT_COUNTER.getValue()
                        .replace("${CHECKPOINTS_PASSED_PERCENTAGE}", String.valueOf(passedCheckpoints * 360d / checkpoints.size()))
                        .replace("${CHECKPOINTS_TOTAL}", String.valueOf(checkpoints.size()))
                        .replace("${CHECKPOINTS_PASSED}", String.valueOf(passedCheckpoints))
                        .replace("${CHECKPOINTS_FAILED}", String.valueOf(failedCheckpoints))
                        .replace("${CHECKPOINTS_DETAILS}", detailsBuilder));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy