Writing JUnit test cases takes time, especially if you want to test a whole system thoroughly.
Testing a Java class at random is unlikely to cover many of its complex constructs and scenarios.
However, it is possible to treat test generation as an optimization problem, and then use techniques like Genetic Algorithms to address it.
In this talk, I will first describe how one could use Java reflection to build a random testing tool.
Then, I will briefly describe how Genetic Algorithms work, and how they can be applied to automated test case generation.
Such techniques are demonstrated with the open-source tool called EvoSuite (https://github.com/EvoSuite/evosuite).