{{announcement.body}}
{{announcement.title}}

DevOps Your Skill: Integration Tests

DZone 's Guide to

DevOps Your Skill: Integration Tests

In this article, we discuss how to make integration tests in Alexa Skills in your pipeline and its importance in the day-to-day Alexa Skills development.

· DevOps Zone ·
Free Resource

Integration tests ensure that the components of an application is running properly at a level that includes the auxiliary infrastructure of the application, such as the voice user interface, the backend, and the integration with external systems.

Integration tests evaluate the components of an application at a higher level than unit tests. Unit tests are used to test isolated software components, such as individual class methods. Integration tests check that two or more components of an application work together, and they generate an expected result, possibly including all the components necessary to fully process a request.

These tests are automated in the continuous integration system (CircleCI) and are executed in each new version of the software.

Prerequisites

Here you have the technologies used in this project

  1. ASK CLI - Install and configure ASK CLI.
  2. CircleCI Account - Sign up here.
  3. Node.js v10.x.
  4. Visual Studio Code.

ASK CLI (Alexa Skill Kit CLI)

The Alexa Skills Kit Command Line Interface (ASK CLI) is a tool for you to manage your Alexa skills and related resources, such as AWS Lambda functions. With ASK CLI, you have access to the Skill Management API, which allows you to manage Alexa skills programmatically from the command line. We will use this powerful tool to test our Voice User Interface. Let's start!

Installation

The ASK CLI and the bash tool expect are included in the Docker image we are using, so it is not necessary to install anything else.

Writing Integration Tests

In this step of the pipeline we are going to develop some tests written in bash using the ASK CLI.

Once we have tested our Voice User Interface and we check that everything is correct. It is time to test all software components related in an Alexa Skill request.

This integration tests can be performed with the ASK CLI. we will use the following ASK CLI command:

  1. For ask CLI v1 and v2:
Shell
 


With this command, we will perform a simulation of a dialog with our Alexa Skill using plain text as input. So with that, we can test that all software components are running properly.

Those commands are integrated in the bash script file test/integration-test/simple-dialog-checker.sh.

Here you can find the full bash script:

Shell
 




x
16


1
    #!/usr/bin/expect
2
 
          
3
    set skill_id [lindex $argv 0];
4
 
          
5
    spawn ask dialog -s ${skill_id} -l es-ES
6
    expect "User"
7
    send -- "abre hola mundo\r"
8
    expect "Bienvenido, puedes decir Hola o Ayuda. Cual prefieres?"
9
    send -- "hola\r"
10
    expect "Hola Mundo!"
11
    send -- "abre hola mundo\r"
12
    expect "Bienvenido, puedes decir Hola o Ayuda. Cual prefieres?"
13
    send -- "ayuda\r"
14
    expect "Puedes decirme hola. Cómo te puedo ayudar?"
15
    send -- "adios\r"
16
    expect "Hasta luego!"



Reports

There are not reports defined in this job.

Integration

It is not necessary to integrate it in package.json file.

Pipeline Job

Everything is ready to run our integration tests, let's add it to our pipeline!

This job will execute the following tasks:

  1. Restore the code that we have downloaded in the previous step in /home/node/project folder
  2. Run the simple-dialog-checker script.
  3. Persist again the code that we will reuse in the next job
YAML
 




x
10


1
  integration-test:
2
    executor: ask-executor
3
    steps:
4
      - attach_workspace:
5
          at: /home/node/
6
      - run: cd test/integration-test/ && ./simple-dialog-checker.sh $SKILL_ID
7
      - persist_to_workspace:
8
          root: /home/node/
9
          paths:
10
            - project



NOTE: To perform these tests in CircleCI you have to set the environment variable SKILL_ID with the id of your Alexa Skill.

Resources

Conclusion

Check that all components of our application are running properly is one of the most important things in every pipeline. These tests are used to test the application infrastructure and its components. This is why these tests are very relevant in our pipeline. Thanks to the ASK CLI we can perform this complex tests.

You can write integration tests with Bespoken as well. See documentation here. And set type test to simulation isntead of e2e

That’s all, folks!  

You can find the code in my GitHub.

I hope it will be useful! If you have any doubts or questions, do not hesitate to contact me or put a comment below.

Happy coding!

Topics:
alexa, alexa app development, alexa skill, alexa skill development, alexa skills, alexa skills developer, alexa skills development, devops, integration test, test

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}