package com.banesco.tests;

import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestWatcher;

import java.util.Optional;

public class BanTestWatcher implements TestWatcher {
    private static final String ANSI_GREEN = "\u001B[32m";
    private static final String ANSI_RED = "\u001B[31m";
    private static final String ANSI_RESET = "\u001B[0m";

    @Override
    public void testSuccessful(ExtensionContext context) {
        System.out.println(ANSI_GREEN + "Test successful: " + context.getDisplayName() + ANSI_RESET);
    }

    @Override
    public void testFailed(ExtensionContext context, Throwable cause) {
        System.out.println(ANSI_RED + "Test failed: " + context.getDisplayName() + " - " + cause.getMessage() + ANSI_RESET);
    }

    @Override
    public void testDisabled(ExtensionContext context, Optional<String> reason) {
        System.out.println("Test disabled: " + context.getDisplayName() + " - " + reason.orElse("No reason given"));
    }
}