Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing Alexa Skill

Testing Alexa Skill

JAWS-UG KOBE Alexa meetup #09

参考資料
- Workshopサンプル・ドキュメント一式
 https://github.com/alexa/skill-sample-nodejs-test-automation
- セッションスライド
 https://www.slideshare.net/AmazonWebServices/alx315test-automation-for-alexa-skills
- Alexa Skills Kit公式ドキュメント
 https://developer.amazon.com/ja/alexa-skills-kit
- 一人Alexa Skills Kit for Node.js Advent Calendar 2017
 https://qiita.com/advent-calendar/2017/alexa-skills-kit-for-nodejs

75486cbfd37125f121cf4a6c5614601c?s=128

Hidetaka Okamoto
PRO

December 20, 2017
Tweet

Transcript

  1. 5FTUJOH"MFYB4LJMM +"846(,0#&"MFYBNFFUVQ

  2. H i d e t a k a O k

    a m o t o • Digitalcube Co. Ltd. • JAWS-UG Kyoto, Kobe • WordCamp Kyoto 2017
  3. "MFYB4LJMM͍Ζ͍Ζ࡞ͬͯ·͢ʢ೔ӳʣ IUUQTEFWFMPQFSBNB[PODPNFEXIPNFIUNMTLJMMT

  4. 5FTU"VUPNBUJPOGPS"MFYB4LJMMT IUUQTXXXTMJEFTIBSFOFU"NB[PO8FC4FSWJDFTBMYUFTUBVUPNBUJPOGPSBMFYBTLJMMT

  5. w ͳͥςετΛ΍Δ΂͖ͳͷ͔ w "MFYB4LJMMͰͷςετͷछྨ w "84-BNCEBº/PEFKTͰͷϢχοτςετ w ӡ༻؂ࢹͱͯ͠ͷςετ "HFOEB

  6. w ͳͥςετΛ΍Δ΂͖ͳͷ͔ w "MFYB4LJMMͰͷςετͷछྨ w "84-BNCEBº/PEFKTͰͷϢχοτςετ w ӡ༻؂ࢹͱͯ͠ͷςετ "HFOEB

  7. ެ։ͨ͠"MFYB4LJMM͸"NB[POʹܝࡌ͞ΕΔ IUUQTXXXBNB[PODPNTSFGOC@TC@OPTT VSMTFBSDIBMJBT%BMFYBTLJMMT

  8. ಈ͔ͳ͍εΩϧ͸੕̍ͭʹͳΔ

  9. ͪΌΜͱಈ͘͜ͱΛ อূ͍ͨ͠

  10. w ͳͥςετΛ΍Δ΂͖ͳͷ͔ w "MFYB4LJMMͰͷςετͷछྨ w "84-BNCEBº/PEFKTͰͷϢχοτςετ w ӡ༻؂ࢹͱͯ͠ͷςετ "HFOEB

  11. "MFYBEBUBqPX E c h o D e v i c

    e A u t o m a t i c S p e e c h R e c o g n i t i o n R e q u e s t h a n d l e r s AW S L a m b d a N a t u r a l L a n g u a g e U n d e r s t a n d i n g
  12. &DIPTJNJP IUUQTFDIPTJNJP

  13. "MFYBEBUBqPX E c h o D e v i c

    e A u t o m a t i c S p e e c h R e c o g n i t i o n R e q u e s t h a n d l e r s AW S L a m b d a N a t u r a l L a n g u a g e U n d e r s t a n d i n g E c h o S i m . i o AV S A P I
  14. "4,$-* IUUQTEFWFMPQFSBNB[PODPNKBEPDTTNBQJBTLDMJDPNNBOESFGFSFODFIUNM

  15. "MFYBEBUBqPX E c h o D e v i c

    e A u t o m a t i c S p e e c h R e c o g n i t i o n R e q u e s t h a n d l e r s AW S L a m b d a N a t u r a l L a n g u a g e U n d e r s t a n d i n g E c h o S i m . i o A S K C L I AV S A P I A S K S M A P I S k i l l S i m u l a t i o n A P I S k i l l I n v o c a t i o n A P I
  16. 4FSWJDF4JNVMBUPS IUUQTEFWFMPQFSBNB[PODPNFEXIPNFIUNM

  17. 5FTUJOH4JNVMBUPS CFUB IUUQTEFWFMPQFSBNB[PODPNFEXIPNFIUNM

  18. "MFYBEBUBqPX E c h o D e v i c

    e A u t o m a t i c S p e e c h R e c o g n i t i o n R e q u e s t h a n d l e r s AW S L a m b d a N a t u r a l L a n g u a g e U n d e r s t a n d i n g E c h o S i m . i o A S K C L I S e r v i c e S i m u l a t o r AV S A P I A S K S M A P I S k i l l S i m u l a t i o n A P I S k i l l I n v o c a t i o n A P I
  19. 6OJUUFTUUPPMT NPDIBKFTUFUDʜ IUUQTNPDIBKTPSH

  20. "MFYBEBUBqPX E c h o D e v i c

    e A u t o m a t i c S p e e c h R e c o g n i t i o n R e q u e s t h a n d l e r s AW S L a m b d a N a t u r a l L a n g u a g e U n d e r s t a n d i n g E c h o S i m . i o A S K C L I S e r v i c e S i m u l a t o r U n i t t e s t t o o l s AV S A P I A S K S M A P I S k i l l S i m u l a t i o n A P I S k i l l I n v o c a t i o n A P I U n i t t e s t S D K
  21. ςετ͍ͨ͠ ϨΠϠʹԠͨ͡ πʔϧͷႩఆΛ

  22. w ͳͥςετΛ΍Δ΂͖ͳͷ͔ w "MFYB4LJMMͰͷςετͷछྨ w "84-BNCEBº/PEFKTͰͷϢχοτςετ w ӡ༻؂ࢹͱͯ͠ͷςετ "HFOEB

  23. "MFYBDPOWFSTBUJPO OQNJOTUBMMTBWFEFWBMFYBDPOWFSTBUJPO

  24. "MFYBDPOWFSTBUJPOͷUFTUqPX E c h o D e v i c

    e A u t o m a t i c S p e e c h R e c o g n i t i o n R e q u e s t h a n d l e r s AW S L a m b d a N a t u r a l L a n g u a g e U n d e r s t a n d i n g E c h o S i m . i o A S K C L I S e r v i c e S i m u l a t o r U n i t t e s t t o o l s AV S A P I A S K S M A P I S k i l l S i m u l a t i o n A P I S k i l l I n v o c a t i o n A P I U n i t t e s t S D K
  25. ϓϩδΣΫτͷηοτΞοϓ $ npm init -y $ npm install —save alexa-sdk

    $ npm install --save-dev alexa-conversation mocha
  26. IBOEMFSΛ࣮ߦ͢Δ४උ IUUQTXQLZPUPOFUUFTUCZBMFYBDPOWFSTBUJPO // ϥΠϒϥϦͷಡΈࠐΈ const conversation = require('alexa-conversation') // ςετର৅ͷϑΝΠϧͷಡΈࠐΈ

    const app = require('../index.js') const opts = { name: 'Alexa Sample App', // ςετ໊ʢʣ appId: 'your-app-id', // ΞϓϦIDʢμϛʔͰOK)ʣ app: app, // ςετର৅ handler: app.handler // ࣮ߦ͢ΔϓϩύςΟ }
  27. *OUFOUͱ4MPUͰςετΛॻ͍͍ͯ͘ IUUQTXQLZPUPOFUUFTUCZBMFYBDPOWFSTBUJPO conversation(opts) .userSays('LaunchRequest') .plainResponse .shouldContain('αϯϓϧεΩϧ΁Α͏ͦ͜ɻ') .userSays('SampleIntent', {slotOne: 'slotValue'}) .plainResponse

    .shouldContain(slotOne͸slotValueͰͨ͠ɻ') .userSays('AMAZON.StopIntent') .plainResponse .shouldContain('·ͨͷ͝ར༻Λ͓଴ͪͯ͠·͢ɻ') .end()
  28. 44.-΍BUUSJCVUFT΋ςετ͢Δྫ IUUQTXQLZPUPOFUUFTUBMFYBTELBQQCZNPDIBBOEQPXFSBTTFSU

  29. *OUFOUͱ4MPUͰςετΛॻ͍͍ͯ͘ IUUQTXQLZPUPOFUUFTUCZBMFYBDPOWFSTBUJPO conversation(opts) .userSays('LaunchRequest') .plainResponse .shouldContain('αϯϓϧεΩϧ΁Α͏ͦ͜ɻ') .userSays('SampleIntent', {slotOne: 'slotValue'}) .plainResponse

    .shouldContain(slotOne͸slotValueͰͨ͠ɻ') .userSays('AMAZON.StopIntent') .plainResponse .shouldContain('·ͨͷ͝ར༻Λ͓଴ͪͯ͠·͢ɻ') .end()
  30. $*αʔϏεͱ૊Έ߹Θͤͨࣗಈςετ IUUQTXQLZPUPOFUDJCZUSBWJTUPUFTUBMFYBDVTUPNTLJMM

  31. ίʔσΟϯά࣌΍ σϓϩΠ࣌ʹόάΛ ະવʹ๷͙

  32. ࣮࣭"84-BNCEBͷςετͳͷͰɾɾɾ IUUQTTQFBLFSEFDLDPNUXBEBUFTUBCMFMBNCEBXPSLJOHF⒎FDUJWFMZXJUIMFHBDZMBNCEB

  33. w ͳͥςετΛ΍Δ΂͖ͳͷ͔ w "MFYB4LJMMͰͷςετͷछྨ w "84-BNCEBº/PEFKTͰͷϢχοτςετ w ӡ༻؂ࢹͱͯ͠ͷςετ "HFOEB

  34. -BNCEB$MPVE8BUDI ЋͰӡ༻؂ࢹ IUUQTXXXTMJEFTIBSFOFU"NB[PO8FC4FSWJDFTBMYUFTUBVUPNBUJPOGPSBMFYBTLJMMT

  35. 4LJMMͷϦΫΤετΛ࠶ݱͯ͠ςετ͢Δ IUUQTXXXTMJEFTIBSFOFU"NB[PO8FC4FSWJDFTBMYUFTUBVUPNBUJPOGPSBMFYBTLJMMT

  36. "MFYB4LJMMT,JU5FTUJOH'8 +BWB IUUQTHJUIVCDPN,BZ-FSDIBMFYBTLJMMTLJUUFTUFSKBWB

  37. ςετ͸:".-ϑΝΠϧΛ4ʹઃஔ͢Δܗ IUUQTHJUIVCDPNBMFYBTLJMMTBNQMFOPEFKTUFTUBVUPNBUJPOCMPC NBTUFSTDSJQUTMBCZNM configuration: endpoint: type: InvocationApi region: NA locale:

    en-US GuessFive: &GuessFive - intent: GuessNumber - number: 5 - response.shouldEndSession == false - response.outputSpeech.ssml =~ /.*My number is higher.*/i : <<do something>> Launch: - response.shouldEndSession == false - *GuessFive
  38. $MPVE'PSNBUJPOͰؙ͝ͱىಈՄೳ IUUQTHJUIVCDPNBMFYBTLJMMTBNQMFOPEFKTUFTUBVUPNBUJPOCMPCNBTUFSMBCTMBCNE

  39. w "MFYB4LJMM΋ͪΌΜͱςετ͠Α͏ w ςετ͍ͨ͠ൣғʹԠͨ͡πʔϧબఆΛ w $*Ͱͷ༧๷ࡦͱ$8& 4/4Ͱͷӡ༻؂ࢹ w ςετۦಈͳΒ͍͍ͪͪ&DIPʹ࿩͔͚͠ͳͯ͘΋εΩϧ࡞ΕΔΑ ·ͱΊ

  40. ΋ͬͱ"MFYBͷ࿩Λฉ͖͍ͨํ͸ IUUQTBMFYBEBZKBXTVHKQ

  41. w 8PSLTIPQαϯϓϧɾυΩϡϝϯτҰࣜ ɹIUUQTHJUIVCDPNBMFYBTLJMMTBNQMFOPEFKTUFTUBVUPNBUJPO w ηογϣϯεϥΠυ ɹIUUQTXXXTMJEFTIBSFOFU"NB[PO8FC4FSWJDFTBMYUFTUBVUPNBUJPOGPSBMFYBTLJMMT  w "MFYB4LJMMT,JUެࣜυΩϡϝϯτ ɹIUUQTEFWFMPQFSBNB[PODPNKBBMFYBTLJMMTLJU

    w Ұਓ"MFYB4LJMMT,JUGPS/PEFKT"EWFOU$BMFOEBS ɹIUUQTRJJUBDPNBEWFOUDBMFOEBSBMFYBTLJMMTLJUGPSOPEFKT ࢀߟࢿྉͳͲ