diff --git a/tests.js b/tests.js index a04137f..bacaec0 100644 --- a/tests.js +++ b/tests.js @@ -56,6 +56,21 @@ function next() { } } +/** + * Randomize array element order in-place. + * Using Durstenfeld shuffle algorithm. + * See http://stackoverflow.com/a/12646864 + */ +function shuffle(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + return array; +} + tests = [ // Page loads with status of 'success' @@ -602,4 +617,5 @@ page.open(url, function(status) { ]; console.log("Running tests..."); +tests = shuffle(tests); next();