Class TestEnvironment


  • public class TestEnvironment
    extends Object
    Provides the environment for running JUnit tests.
    • Field Detail

      • timeoutMillis

        private long timeoutMillis
        The process timeout in milliseconds. Defaults to 20 minutes.
      • testClasspath

        private final String testClasspath
        The classpath for the tests.
      • replaceCallAgentPath

        private Path replaceCallAgentPath
        The path for the replacecall agent.
      • replaceCallAgentArgs

        private String replaceCallAgentArgs
        The argument string for the replacecall agent.
    • Constructor Detail

      • TestEnvironment

        public TestEnvironment​(String testClasspath)
        Creates a test environment with the given classpath and an empty agent map.
        Parameters:
        testClasspath - the class path for running the tests
    • Method Detail

      • addAgent

        public void addAgent​(Path agentPath,
                             String agentArgumentString)
        Adds the path for a javaagent jar file to the agent map. These agents will be included in the command in the order they are added.
        Parameters:
        agentPath - the path to the Javaagent jar file
        agentArgumentString - the argument string for the agent
      • setReplaceCallAgent

        public void setReplaceCallAgent​(Path agentPath,
                                        String agentArgs)
        Sets the path and arguments for the replace call agent. This agent has to be placed on the boot classpath.
        Parameters:
        agentPath - the path for the replacecall agent
        agentArgs - the arguments for running the agent
      • setTimeoutMillis

        public void setTimeoutMillis​(long timeoutMillis)
        Set the test execution timeout.
        Parameters:
        timeoutMillis - the time in milliseconds that a test is allowed to run before being terminated
      • commandPrefix

        private List<String> commandPrefix()
        Constructs the command to run JUnit tests in this environment, minus the name of the test class. Adding the test class name is sufficient to build a runnable command.
        Returns:
        the base command to run JUnit tests in this environment, without a test class name
      • getJavaagentOption

        private String getJavaagentOption​(Path agentPath,
                                          String args)