02 - Launching executions on targets
The Target type
When is a target used?
A Target represents the system under test, on which a command will be applied.
Let's have a look at the following instructions:
EXECUTE execute WITH bundle ON website USING conf AS result
website is a target of the type WebTarget
How to define a target?
All targets need to be annotated @TATarget("NAME")
NAME is the name on the shebang given to the target
For example, the resource WebTarget which was spoken of above is defined as:
@TATarget("http")
public class WebTarget implements Target
... and its actual file looks like:
#!http
squashtest.ta.http.endpoint.url=http://random-site.com
squashtest.ta.http.https=false
The Command type
When is a command used?
A Command will perform an operation on a target by applying a resource on it in a special way.
Let's have a look at the following instruction:
EXECUTE execute WITH bundle ON website USING conf AS result
execute is a command of the type SahiExecuteSuiteCommand, which is performed on a WebTarget by applying a SahiSuiteResource.
How to define a command?
All the Commands needs to be annotated @TACommand("NAME")
NAME is the name given to the EXECUTE instruction.
All the Commands must implement the interface Command<RESOURCE, TARGET>
RESOURCE is the type of the resource given to the instruction (the WITH clause),
TARGET is the type of the target given to the instruction (the ON clause).
For example, the command SahiExecuteSuiteCommand which was spoken of above is defined as:
@TACommand("execute")
public class SahiExecuteSuiteCommand implements Command<SahiSuiteResource, WebTarget>
Note: If a command doesn’t need a Resource, a target (or both, why not?) it must use VoidResource and VoidTarget.