Thursday, June 9, 2016

How to write Data Driven tests in Javascript

I know how to write "Parameterized tests" in Java and Data Driven tests in Groovy using Spock framework. But how to write in JavaScript? Now I try to show how to make it working using mocha framework.

Data Driven tests in Mocha is called "Dynamically generated tests", based on the API documentation, there are 2 steps:
  1) Create a test data array;
  2) Iterate the test data, generate the test case dynamically,  the test case name in "it" block is also generated dynamically, which is quite similar with Spock framework.

The implementation is pretty straight forward. Here is the example of my implementation in the Tennis Game Kata:
  https://github.com/stevez/TennisGame-solution/blob/master/javascript/test/Tennis-test.js
 The javascript example project is here:
 https://github.com/stevez/TennisGame-solution/tree/master/javascript

Next step I will look at how to work it using Jasmine framework.

19 comments:

  1. nice work, here are some games I program Planeta 42 :)

    ReplyDelete
  2. dominoqq online yang merupakan salah satu jenis permainan paling menarik untuk dimainkan bagi petaruh judi di
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terpercaya
    hobiqq
    paito warna terlengkap
    bocoran sgp

    ReplyDelete
  3. http://aswidhafm.blogspot.com/2013/04/berita-kesehatan-terbaru-penemuan.html
    http://dial-africa.blogspot.com/2013/11/orchestre-kiam-kamiki-african-91228.html
    https://miniaplikace.blueboard.cz/kniha/xmcj77u5s21i48mhuen7o4tufktohn
    https://www.b2bmarketingexpert.com/2019/04/salesforce-data-migrations-with-david-masri-capgemini.html?showComment=1570077340870#c7289857674520271246
    https://nsmnss.blogspot.com/2012/11/deep-data-digging-into-social-media_16.html?showComment=1570077327208#c3513490535468670348
    https://cloudepr.blogspot.com/2010/07/my-comments-to-cassandra-at-twitter.html?showComment=1570077332224#c1316193986723886381
    https://istribandot.blogspot.com/2019/03/pangerantoto2-data-keluaran-prediksi.html?showComment=1570077444941#c926150375211369591
    https://internetofthinking.blogspot.com/2016/02/upload-ds18b20-temperature-sensor-data.html?showComment=1570077337622#c5314752666873526118
    https://code-dojo.blogspot.com/2016/06/how-to-write-data-driven-tests-in.html?showComment=1570077383552#c4109714307688575878

    ReplyDelete
  4. SaranaPelangi merupakan salah satu situs permainan kartu Online terbaik, aman dan terpercaya dengan persentase kemenangan yang tinggi saat ini di Indonesia. Situs ini juga menyediakan berbagai macam permainan kartu Online uang asli yang populer dengan sistem dan server stabil yang mudah di akses kapanpun dan dimanapun.

    ReplyDelete