blob: 69a394ca886f923da384da1ee0b0219af5a529b1 [file]
= Robot Framework Component
:doctitle: Robot Framework
:shortname: robotframework
:artifactid: camel-robotframework
:description: Pass camel exchanges to acceptance test written in Robot DSL.
:since: 3.0
:supportlevel: Stable
:tabs-sync-option:
:component-header: Both producer and consumer are supported
*Since Camel {since}*
*{component-header}*
The *robotframework:* component allows for processing camel exchanges
in acceptance test suites which are already implemented with its own DSL.
The depending keyword libraries that can be used inside test suites
implemented in Robot DSL, could have been implemented either via
Java or Python.
This component will let you execute business logic of acceptance test cases
in Robot language on which you can pass parameters to feed data via power
of Camel Routes.
However, there is no reverse binding of parameters back where
you can pass values back into Camel exchange. Therefore, for that reason,
it actually acts like a template language passing camel exchanges by binding
data into the test cases implemented.
[source,xml]
----
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-robotframework</artifactId>
<version>x.x.x</version> <!-- use the same version as your Camel core version -->
</dependency>
----
== URI format
----
robotframework:templateName[?options]
----
Where *templateName* is the classpath-local URI of the template to
invoke; or the complete URL of the remote template (eg:
\file://folder/myfile.robot).
// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
include::partial$component-endpoint-headers.adoc[]
// component options: END
== Examples
For example, you could use something like:
[tabs]
====
Java::
+
[source,java]
----
from("direct:setVariableCamelBody")
.to("robotframework:src/test/resources/org/apache/camel/component/robotframework/set_variable_camel_body.robot");
----
XML::
+
[source,xml]
----
<route>
<from uri="direct:setVariableCamelBody"/>
<to uri="robotframework:src/test/resources/org/apache/camel/component/robotframework/set_variable_camel_body.robot"/>
</route>
----
YAML::
+
[source,yaml]
----
- route:
from:
uri: direct:setVariableCamelBody
steps:
- to:
uri: robotframework:src/test/resources/org/apache/camel/component/robotframework/set_variable_camel_body.robot
----
====
To use a robot test case to execute and collect the results
and pass them to generate a custom report if such need happens
It's possible to specify what template the component
should use dynamically via a header, so for example:
._Java-only: dynamic template via header_
[source,java]
----
from("direct:in")
.setHeader("CamelRobotResourceUri").constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
----
Robotframework component helps you pass values into robot test cases
with the similar approach how you would be able to pass values using
Camel Simple Language. Components support passing values in three
different ways. Exchange body, headers, and properties.
._Java-only: dynamic template via header_
[source,java]
----
from("direct:in")
.setBody(constant("Hello Robot"))
.setHeader("CamelRobotResourceUri").constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
----
And the `template.robot` file:
[source,text]
----
*** Test Cases ***
Set Variable Camel Body Test Case
${myvar} = Set Variable ${body}
Should Be True ${myvar} == ${body}
----
._Java-only: dynamic template via header_
[source,java]
----
from("direct:in")
.setHeader("testHeader", constant("testHeaderValue"))
.setHeader("CamelRobotResourceUri").constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
----
And the `template.robot` file:
[source,text]
----
*** Test Cases ***
Set Variable Camel Header Test Case
${myvar} = Set Variable ${headers.testHeader}
Should Be True ${myvar} == ${headers.testHeader}
----
._Java-only: dynamic template via header_
[source,java]
----
from("direct:in")
.setProperty"testProperty", constant("testPropertyValue"))
.setHeader("CamelRobotResourceUri").constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
----
And the `template.robot` file:
[source,text]
----
*** Test Cases ***
Set Variable Camel Header Test Case
${myvar} = Set Variable ${properties.testProperty}
Should Be True ${myvar} == ${properties.testProperty}
----
Please note that when you pass values through Camel Exchange to test cases,
they will be available as case-sensitive ``body``, ``headers.[yourHeaderName]`` and ``properties.[yourPropertyName]``