Data-driven tests
There are times where a set of tests for the same piece of code needs to be repeated over and over with slightly different inputs. If you were testing the ability of a function to recognize the occurrence of a string, for example, you would want to hit that test with multiple different strings. These sorts of tests are called data-driven tests. The outcome of each test would be the same, but we need to make sure that we are testing our code under multiple different circumstances.
To show how extensible the Jasmine testing library is, J P Castro wrote a very short, but powerful utility to provide data-driven tests within Jasmine. His blog on this topic can be found at http://blog.jphpsf.com/2012/08/30/drying-up-your-javascript-jasmine-tests/ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access