Population { public void calculateFitnessForAll(Function<Chromosome, Double> fitnessFunction) { for (int i = 0; i < chromosomes.length; i++) calculateFitnessForChromosome(i, fitnessFunction); } Population(int size); Chromosome getChromosome(int idx); double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction); void calculateFitnessForAll(Function<Chromosome, Double> fitnessFunction); void setChromosome(int idx, Chromosome chromosome); Chromosome getChromosome(Integer idx); Chromosome[] selectBestKChromosome(int k); double getTotalFitness(); double getAverageFitness(); int size(); void setFitness(Integer idx, Double fitness);  }
@Test public void calculateFitnessForAll() { population.calculateFitnessForAll(fitnessFunction); Assert.assertEquals(population.getChromosome(0).getFitness(), 0, PRECISION); }