I'm trying to write test for my skill.
I'm using Behave framework.
In the mycroft documentation when is explaimed how write a test with Behave is shown a possibility to check if the mycroft reply contain or not a specific word.
But all the ways presented does not work for me.
I tried:
Where is the mistake?
I have to use the key-word "contain" or "include"?
Hi seems like the syntax for containing a word should be
Then mycroft reply should contain "SOMETHING CLEVER"
Where SOMETHING CLEVER is the expected clever response from mycroft :)
See here for the definition and an example can be found in the wiki skill.
I haven't seen a "should not include" step, I see it referenced in the docs but I think that's mainly an example...
I think the problem is most simply.
If you note the definiton of "should contains" don't use attribute {skill} like the other step, so to use this step we must write "Then mycroft... " and not "Then {skillname}..."
Compare two this definition...
@then('mycroft reply should contain "{text}"')
and not like the other step
@then('"{skill}" should reply with exactly "{text}"')
Hey, I've changed that example in the docs. That was a mistake on my part.
The broader "mycroft reply" Steps are useful when you don't actually care which Skill responds as long as you get a good answer. For example asking a general knowledge question like the height of the Eiffel tower - it might be DuckDuckGo, Wikipedia, or Wolfram Alpha that answer, but either way it's still a successful interaction.
Thanks for raising the issue though, I think these are all good candidates to add as new Steps:
Ok. Thanks so much. Now it's clear how to use then_contains step.
I have also a problem with this example:
`Feature: current-weather
Scenario: Temperature in paris
Given an english speaking user
And user is located in Paris
When the user says "how hot will it be today"
Then "mycroft-weather" should reply with dialog from "current.high.temperature.dialog"
But mycroft reply should contain "Paris"`
When i use But or And doesn't seems that the check of the word that reply have to contain is done on the previous reply, but seems that work as the usual
Then mycroft reply should contain...
, so it seems that also usign But|And, behave attends for a new reply to check if the reply contains the specific word.
Also in the definiton of the behave step there is no reference about a contain step that work on a previous reply with And or But keyword.
Edit:
This behaviour is the normal behaviour of behave.
But
and And
does not work on the previous reply, but they are useful to make more readable the test.
If you write
"Then "myskil" should reply with dialog "myskill.dialog"
"And|But "myskill" should reply with dialog "myskillother.dialog"
Is the same of
"Then "myskil" should reply with dialog "myskill.dialog"
"Then "myskill" should reply with dialog "myskillother.dialog"
So and|but
are be substitute with then|given
depending on the type of the previous step, if previous step is a then
step will be substitute with then
otherwise with given
.
So in the case of then_contain is the same, the check is done on a new spoken utterance not on the previous.
This also because the mycroft message bus does not save the responses given, so when a response is consumate then is not possibile have access on it.
See pull request #2711 and issue #2714
Most helpful comment
Hey, I've changed that example in the docs. That was a mistake on my part.
The broader "mycroft reply" Steps are useful when you don't actually care which Skill responds as long as you get a good answer. For example asking a general knowledge question like the height of the Eiffel tower - it might be DuckDuckGo, Wikipedia, or Wolfram Alpha that answer, but either way it's still a successful interaction.
Thanks for raising the issue though, I think these are all good candidates to add as new Steps: