From fb3726873f9dd6d7319388a1a5e472042098248b Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 18:25:38 +1000 Subject: Test order is randomized --- tests.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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(); -- cgit v1.2.3