I create a board with items and these items are created randomly for a game which is some kind of a match-3 game. There are some cases that I want to test. Can you suggest any methodology to test cases that are produced randomly?
Best
I create a board with items and these items are created randomly for a game which is some kind of a match-3 game. There are some cases that I want to test. Can you suggest any methodology to test cases that are produced randomly?
Best
Using TestNG, you can use 'Parametrized' tests, and seed them via any data provider: http://www.mkyong.com/unittest/testng-tutorial-6-parameterized-test/, e.g. a simple csv file.
You might want to start with an extensive list of possible inputs, and afterwards find a set of inputs that gives you the highest coverage of your class under test.
Test coverage tools can check if each possible execution path of your code was reached during the test with the given inputs.
Maybe that's not enough, but to reverse engineer the possible inputs that gives a certain output is more of a task for artificial intelligence engines.
For test Scenarios containing random(e.g. Numbers), you need a RandomGenerator, where you can set the Seed
. If the Seed is the same, the generated Numbers will always be the same, in the same order. For the test you set the Seed to a fixed value, for the real application you will use a variable value like System.getMilliSeconds()
. So you can check the correctness of your test result for one Seed, after that you can repeat your tests as often as you want, if the results changes, but your Seed not you found an Error-Case.