I often need to perform the exact same task. Fuzz testing is an appropriate approach, although we must be careful to distinguish between raw fusers and smart fusers. Intelligent fuzzer is different than a regular fuzz tool (like zzuf ) because it creates data designed for your application. Obviously, in this case you need a smart fuser.
To write an intelligent fuzzer, you will need to extract those rules that will be “consistent and consistent” and use them as logical ones. Probably the best example. There Modelis some logic in the class below.
class Model {
int a;
List<Model> children;
boolean isRoot;
}
We can write a test data builder for this by simply coding these rules.
class ModelGenerator {
private Random random;
public ModelGenerator(int seed) {
random = new Random(seed);
}
public Model arbitrary () {
return generateSingleItem(true);
}
private Model generateSingleItem(boolean isRoot) {
Model model = new Model();
model.isRoot = isRoot;
model.a = random.nextInt(10);
int childrenCount = random.nextInt(100);
model.children = new ArrayList<Model>(childrenCount);
for (int i=0;i<childrenCount;++i) {
model.children.add(generateSingleItem(false));
}
return model;
}
}
( ) , .
QuickCheck. Java, ( !), .