public class TestEnvironment
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.LinkedHashMap<java.nio.file.Path,java.lang.String> |
agentMap
A map from javaagent jar path to argument string.
|
private java.lang.String |
replaceCallAgentArgs
The argument string for the replacecall agent.
|
private java.nio.file.Path |
replaceCallAgentPath
The path for the replacecall agent.
|
private java.lang.String |
testClasspath
The classpath for the tests.
|
private long |
timeoutMillis
The process timeout in milliseconds.
|
Constructor and Description |
---|
TestEnvironment(java.lang.String testClasspath)
Creates a test environment with the given classpath and an empty agent map.
|
Modifier and Type | Method and Description |
---|---|
void |
addAgent(java.nio.file.Path agentPath,
java.lang.String agentArgumentString)
Adds the path for a javaagent jar file to the agent map.
|
private java.util.List<java.lang.String> |
commandPrefix()
Constructs the command to run JUnit tests in this environment, minus the name of the test
class.
|
private java.lang.String |
getJavaagentOption(java.nio.file.Path agentPath,
java.lang.String args) |
RunCommand.Status |
runTest(java.lang.String testClassName,
java.nio.file.Path workingDirectory)
Runs the named JUnit test class in this environment.
|
void |
setReplaceCallAgent(java.nio.file.Path agentPath,
java.lang.String agentArgs)
Sets the path and arguments for the replace call agent.
|
void |
setTimeoutMillis(long timeoutMillis)
Set the test execution timeout.
|
private long timeoutMillis
private final java.lang.String testClasspath
private final java.util.LinkedHashMap<java.nio.file.Path,java.lang.String> agentMap
private java.nio.file.Path replaceCallAgentPath
private java.lang.String replaceCallAgentArgs
public TestEnvironment(java.lang.String testClasspath)
testClasspath
- the class path for running the testspublic void addAgent(java.nio.file.Path agentPath, java.lang.String agentArgumentString)
agentPath
- the path to the Javaagent jar fileagentArgumentString
- the argument string for the agentpublic void setReplaceCallAgent(java.nio.file.Path agentPath, java.lang.String agentArgs)
agentPath
- the path for the replacecall agentagentArgs
- the arguments for running the agentpublic void setTimeoutMillis(long timeoutMillis)
timeoutMillis
- the time in milliseconds that a test is allowed to run before being
terminatedpublic RunCommand.Status runTest(java.lang.String testClassName, java.nio.file.Path workingDirectory) throws RunCommand.CommandException
testClassName
- the fully-qualified JUnit test class nameworkingDirectory
- the working directory for executing the testRunCommand.Status
object for the execution of the test classRunCommand.CommandException
- if there is an error running the test commandprivate java.util.List<java.lang.String> commandPrefix()
private java.lang.String getJavaagentOption(java.nio.file.Path agentPath, java.lang.String args)