def test_seeded_test_case_factory_no_delegation(rand_mock, clear_ips_instance, seed_modules_path, dummy_test_cluster): rand_mock.return_value = 2 ips.initialpopulationseeding.test_cluster = dummy_test_cluster config.configuration.module_name = "primitiveseed" config.configuration.initial_population_seeding = True config.configuration.initial_population_data = seed_modules_path config.configuration.seeded_testcases_reuse_probability = 1.0 ips.initialpopulationseeding.collect_testcases(seed_modules_path) test_factory = TestFactory(dummy_test_cluster) delegate = tcf.RandomLengthTestCaseFactory(test_factory) test_case_factory = tcf.SeededTestCaseFactory(delegate, test_factory) seeded_testcase = test_case_factory.get_test_case() assert (next(iter( seeded_testcase.statements[2].assertions)).value == "Bools are equal!")
def test_seeded_test_case_factory_with_delegation(rand_mock, clear_ips_instance, seed_modules_path, dummy_test_cluster): rand_mock.return_value = 2 ips.initialpopulationseeding.test_cluster = dummy_test_cluster config.configuration.module_name = "primitiveseed" config.configuration.initial_population_seeding = True config.configuration.initial_population_data = seed_modules_path config.configuration.seeded_testcases_reuse_probability = 0.0 ips.initialpopulationseeding.collect_testcases(seed_modules_path) test_factory = TestFactory(dummy_test_cluster) delegate = tcf.RandomLengthTestCaseFactory(test_factory) delegate.get_test_case = MagicMock() test_case_factory = tcf.SeededTestCaseFactory(delegate, test_factory) test_case_factory.get_test_case() delegate.get_test_case.assert_called_once()
def _get_chromosome_factory(self) -> cf.ChromosomeFactory: """Provides a chromosome factory. Returns: A chromosome factory """ # TODO add conditional returns/other factories here test_case_factory: tcf.TestCaseFactory = tcf.RandomLengthTestCaseFactory( self._test_factory ) if config.configuration.initial_population_seeding: test_case_factory = tcf.SeededTestCaseFactory( test_case_factory, self._test_factory ) test_case_chromosome_factory = tccf.TestCaseChromosomeFactory( self._test_factory, test_case_factory ) if config.configuration.algorithm == config.Algorithm.MOSA: return test_case_chromosome_factory return tscf.TestSuiteChromosomeFactory(test_case_chromosome_factory)