actions-on-google / actions-on-google-testing-nodejs

Apache License 2.0
75 stars 18 forks source link

Library Alpha Discussion: Provide action package and get coverage results (i.e. % of intents covered in your tests) #16

Closed atulep closed 5 years ago

atulep commented 6 years ago

Action package lists all of the intents in your project. We can potentially utilize this information to calculate coverage of intents invoked in your tests. For example, suppose your Action will contain 2 intents: A and B. If your test will look like,

action.startTest(‘testing happy path’, action => {
  return action.startConversation().
              then((res) => { action.send(/* some phrase to trigger intent A */) })
})

, then coverage output will be “50 % intents covered (½)”.

yoichiro commented 6 years ago

@atulep Is there a way to get a list of intents dynamically from Actions on Google? Also, how can we recognize that the intent A was triggered in the example above?

Fleker commented 6 years ago

I don't think there's a way to dynamically get intents, but if you pass in the action package from Dialogflow or Actions SDK, we should be able to get all intents. In the action response, you can see the intent that matches. We can track all matched intents versus all intents in general.

image

yoichiro commented 6 years ago

I tested some behaviors, and I noticed the following:

In the case of using Dialogflow, almost intents may be collected from the possibleIntents values by progressing tests. If developers can prepare enough count of test cases, by storing the intent's IDs from the possibleIntents, I guess that we can create the population of the intents.

Fleker commented 6 years ago

If we have a config, where you pass in your Dialogflow zip, we can grab all the ids up front by reading in the files in intents/ (that don't end with says_*.json) to obtain the id

yoichiro commented 6 years ago

@Fleker Yes, I think that it is a simple and certain idea. Basically, this lib's users write a test code. Therefore, they can set the file path of the Dialogflow exported zip file on the test code. For example, my idea is like below:

const { ActionsOnGoogleAva } = require("actions-on-google-testing");
const action = new ActionsOnGoogleAva(require("./credentials.json"));

action.turnOnCoverage({
  dialogflowZipFilePath: '...'
});

action.startTest('...', action => { ... });
action.startTest('...', action => { ... });
...

When starting tests, that is, when the test.before(...) callback function called, we can load the zip file and retrieve the intents ID list. Then, when the test.after(...) callback function called, we can output the coverage report. These processes can be written in the ActionsOnGoogleAva class, I guess.

How do you think above?

Fleker commented 6 years ago

Yeah that's primarily what I envision. Would it make more sense to incorporate it into the constructor?

const action = new ActionsOnGoogleAva(require("./credentials.json", {
    actionPackage: '/path/to/dialogflow.zip'
}));
yoichiro commented 6 years ago

Yes, the idea which uses the constructor also looks good to me. I intend to start implementing this feature.

@Fleker Nick, I want to confirm one point. Is the name actionPackage ok? Actually, the exported zip file from Dialogflow is not an Action Package, is a Dialogflow Agent setting. Is it not possible that developers misunderstand it as a different thing?

Fleker commented 6 years ago

You're correct, technically it should accept either an actionPackage or dialogflowZip parameter.

maaaaaaaax commented 5 years ago

Due to more than 3 months of inactivity, this issue is being closed.

If you think the resolution is in error, please re-open the request with fresh information.