Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behave Test Problem: "Then reply should contain|include" does not work #2709

Open
damorosodaragona opened this issue Sep 30, 2020 · 5 comments
Labels
help wanted Status: For discussion Feature proposal in development. Community input and discussion is invited. Type: Enhancement - proposed New proposal for a feature that is not currently a priority on the roadmap.

Comments

@damorosodaragona
Copy link

damorosodaragona commented Sep 30, 2020

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:

  • Then "mycroft-skill" reply should contain [word]
  • Then "mycroft-skill" should reply with dialog [dialog file] But reply should include [word]
  • Then "mycroft-skill" should reply with dialog [dialog file] Then "mycroft-skill" reply should include [word]
  • Then "mycroft-skill" should reply with dialog [dialog file] But "mycroft-skill" reply should include [word]
  • Then "mycroft-skill" should reply with dialog [dialog file] But reply should contain [word]
  • Then "mycroft-skill" should reply with dialog [dialog file] Then "mycroft-skill" reply should contain [word]
  • Then "mycroft-skill" should reply with dialog [dialog file] But "mycroft-skill" reply should contain [word]

Where is the mistake?
I have to use the key-word "contain" or "include"?

@damorosodaragona damorosodaragona changed the title Behave Test Problem: Then reply should contain does not work Behave Test Problem: "Then reply should contain|include" does not work Sep 30, 2020
@forslund
Copy link
Collaborator

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...

@damorosodaragona
Copy link
Author

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}"')

@krisgesling krisgesling added hacktoberfest help wanted Status: For discussion Feature proposal in development. Community input and discussion is invited. Type: Enhancement - proposed New proposal for a feature that is not currently a priority on the roadmap. labels Oct 1, 2020
@krisgesling
Copy link
Contributor

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:

  • then {skill} reply should contain "{text}"
  • then {skill} reply should not contain "{text}"
  • then mycroft reply should not contain "{text}"

@damorosodaragona
Copy link
Author

damorosodaragona commented Oct 1, 2020

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.

@damorosodaragona
Copy link
Author

See pull request #2711 and issue #2714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Status: For discussion Feature proposal in development. Community input and discussion is invited. Type: Enhancement - proposed New proposal for a feature that is not currently a priority on the roadmap.
Projects
None yet
Development

No branches or pull requests

3 participants