Skip to content

Commit

Permalink
Merge pull request #111 from rock-core/test_changing_properties
Browse files Browse the repository at this point in the history
docs: change the component test documentation to show how to change properties
  • Loading branch information
doudou authored Sep 19, 2024
2 parents 6830e15 + 3e30b7b commit 4ec324f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions source/components/testing.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,21 @@ done with `syskit_write`. Assuming the task under test has an `in` port, for
example:

~~~ ruby
task = syskit_deploy_configure_and_start(
task = syskit_deploy(
OroGen.project_name.Task.deployed_as('task')
)

task.properties.myproperty = 10
task.properties.complex_property = Types.myproject.Complex.nwe(
field: 10
)
# Struct properties must be explicitly written to. You can't modify them in-place
p = task.properties.complex_property
p.some_field = 10
task.properties.complex_property = p

syskit_configure_and_start(task)

sample = Types.project_name.SomeDataType.new
sample.value = 20
expect_execution { syskit_write task.in_port, sample }
Expand All @@ -159,7 +171,7 @@ Calling `syskit_write` more than once with the same port in a single
`expect_execution` statement does not guarantee
the order in which the samples will be received. If you need to queue more than one
sample in a single test, to guarantee ordering, pass all samples instead to a single
`syskit_write` call.
`syskit_write` call.

~~~ ruby
sample1 = ...
Expand Down Expand Up @@ -197,6 +209,10 @@ expect_execution { task.stop! }
.to { EXPECTATIONS }
~~~

If you want to test the start step, replace first `syskit_configure_and_start`
by `syskit_configure`


### Expectations

The two most common expectations are
Expand Down

0 comments on commit 4ec324f

Please sign in to comment.