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

com.context.TestExecutionContext Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
package com.context;

import org.apache.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

public class TestExecutionContext {
    private final String testName;
    private final HashMap testExecutionState;
    private final String NOT_SET = "NOT-YET-SET";
    private static final Logger LOGGER = Logger.getLogger(
            TestExecutionContext.class.getSimpleName());

    public TestExecutionContext(String testName) {
        SessionContext.addContext(Thread.currentThread().getId(), this);
        this.testName = testName;
        this.testExecutionState = new HashMap<>();
        LOGGER.info(String.format("%s - TestExecution context created", testName));
    }

    public String getTestName() {
        return testName;
    }

    public void addTestState(String key, Object details) {
        testExecutionState.put(key, details);
    }

    public Object getTestState(String key) {
        return testExecutionState.get(key);
    }

    public String getTestStateAsString(String key) {
        return (String) testExecutionState.get(key);
    }

    public HashMap getAllTestState() {
        return testExecutionState;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy