For a model based automatic test system it is essential to generate elements of the used data types automatically. In this paper we introduce an elegant algorithm that is able to generate a list of all elements of arbitrary types using generic programming techniques. In order to allow exhaustive testing for finite types we need to be able to determine that all elements of type are generated. This is done by systematic generation of the elements of a type. In order to improve the results of testing we also show a variant of the generation algorithm that yields the elements in a pseudo random order. Both algorithms are very efficient and lazy; only the elements actually needed are generated. Using the interface functions of restricted data types, like search trees, and the algorithms introduced here it is also possible to generate instances of these types. The elements stored in an instance of the search tree are generated by the default generic algorithm.