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

com.shaft.tools.io.internal.ProjectStructureManager 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.cli.FileActions;
import com.shaft.driver.SHAFT;
import com.shaft.properties.internal.Properties;
import com.shaft.tools.io.ReportManager;

import java.nio.file.Paths;

public class ProjectStructureManager {
    public static void initialize(Mode mode) {
        ReportManager.logDiscrete("Initializing Project Structure...");
        SHAFT.Properties.reporting.set().disableLogging(true);
        if (Properties.platform.executionAddress().equals("local")
                && !Paths.get(System.getProperty("user.dir")).getFileName().toString().equals("SHAFT_Engine")) {
            FileActions.getInstance().createFolder(Properties.paths.properties());
            FileActions.getInstance().createFolder(Properties.paths.dynamicObjectRepository());
            FileActions.getInstance().createFolder(Properties.paths.testData());
        }

        // manually override listeners configuration
        if (Properties.platform.executionAddress().equals("local")) {
            FileActions.getInstance().deleteFolder(Properties.paths.services());
            switch (mode) {
                case JUNIT -> {
                    FileActions.getInstance().createFolder(Properties.paths.services());
                    FileActions.getInstance().writeToFile(Properties.paths.services(), "org.junit.platform.launcher.LauncherSessionListener", "com.shaft.listeners.JunitListener");
                }
                case TESTNG -> {
                    FileActions.getInstance().createFolder(Properties.paths.services());
                    FileActions.getInstance().writeToFile(Properties.paths.services(), "org.testng.ITestNGListener", "com.shaft.listeners.TestNGListener");
                }
            }
        }
        // delete previous run execution log
        FileActions.getInstance().deleteFile(System.getProperty("appender.file.fileName"));
        SHAFT.Properties.reporting.set().disableLogging(false);
    }

    public enum Mode {TESTNG, JUNIT}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy