Package randoop.execution
Class TestEnvironment
- java.lang.Object
-
- randoop.execution.TestEnvironment
-
public class TestEnvironment extends Object
Provides the environment for running JUnit tests.
-
-
Field Summary
Fields Modifier and Type Field Description private LinkedHashMap<Path,String>
agentMap
A map from javaagent jar path to argument string.private String
replaceCallAgentArgs
The argument string for the replacecall agent.private Path
replaceCallAgentPath
The path for the replacecall agent.private String
testClasspath
The classpath for the tests.private long
timeoutMillis
The process timeout in milliseconds.
-
Constructor Summary
Constructors Constructor Description TestEnvironment(String testClasspath)
Creates a test environment with the given classpath and an empty agent map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAgent(Path agentPath, String agentArgumentString)
Adds the path for a javaagent jar file to the agent map.private List<String>
commandPrefix()
Constructs the command to run JUnit tests in this environment, minus the name of the test class.private String
getJavaagentOption(Path agentPath, String args)
RunCommand.Status
runTest(String testClassName, Path workingDirectory)
Runs the named JUnit test class in this environment.void
setReplaceCallAgent(Path agentPath, String agentArgs)
Sets the path and arguments for the replace call agent.void
setTimeoutMillis(long timeoutMillis)
Set the test execution timeout.
-
-
-
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.
-
agentMap
private final LinkedHashMap<Path,String> agentMap
A map from javaagent jar path to argument string.
-
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 fileagentArgumentString
- 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 agentagentArgs
- 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
-
runTest
public RunCommand.Status runTest(String testClassName, Path workingDirectory) throws RunCommand.CommandException
Runs the named JUnit test class in this environment.- Parameters:
testClassName
- the fully-qualified JUnit test class nameworkingDirectory
- the working directory for executing the test- Returns:
- the
RunCommand.Status
object for the execution of the test class - Throws:
RunCommand.CommandException
- if there is an error running the test command
-
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
-
-