Exemplo n.º 1
0
 def gen_randoop(self, scenario, project_dep):
     randoop = Randoop(java=project_dep.java,
                       classpath=project_dep.classes_dir,
                       tests_src=project_dep.tests_dst + '/' +
                       project_dep.project.get_project_name() + '/' +
                       scenario.merge_scenario.get_merge_hash(),
                       sut_class=project_dep.sut_class,
                       sut_method=project_dep.sut_method,
                       params=self.randoop_params)
     safira = Safira(java=project_dep.java,
                     classes_dir=project_dep.classes_dir,
                     mutant_dir=project_dep.dRegCp)
     if "Bisect" in project_dep.sut_class:
         self.suite_randoop = randoop.generate()
     else:
         try:
             self.suite_randoop = randoop.generate_with_impact_analysis(
                 safira, True)
         except Exception as e:
             print(e)
             self.suite_randoop = randoop.generate_with_impact_analysis(
                 safira, False)
         if "Simulator" in project_dep.sut_class:
             import distutils.dir_util
             distutils.dir_util.copy_tree("./config/",
                                          randoop.suite_dir + "/config/")
     return self.suite_randoop
Exemplo n.º 2
0
    def test_generate_with_impact_analysis(self):
        tests_src = os.path.join(calculator_project_dir(), 'randoop')
        classes_dir = os.path.join(calculator_target_dir(), 'classes')

        randoop = Randoop(java=self.java,
                          classpath=classes_dir,
                          tests_src=tests_src,
                          sut_class='br.ufal.ic.easy.operations.Sum',
                          sut_classes=['br.ufal.ic.easy.operations.Sum'])
        randoop.parameters = [
            '--time-limit=1', '--testclass=br.ufal.ic.easy.operations.Sum'
        ]

        safira = Safira(self.java, classes_dir, calculator_src_aor_1())

        (suite_name, suite_dir, suite_classes_dir,
         suite_classes) = randoop.generate_with_impact_analysis(safira)

        self.assertTrue(suite_name.startswith('randoop'))
        self.assertTrue(os.path.exists(suite_dir))

        self.assertTrue(len(get_java_files(suite_dir)) > 1)
        self.assertTrue(len(get_class_files(suite_classes_dir)) > 1)
        self.assertEquals(2, len(suite_classes))

        shutil.rmtree(tests_src)
Exemplo n.º 3
0
    def test_run_safira(self):
        safira = Safira(self.java, calculator_target_dir(),
                        calculator_src_aor_1())

        results = safira.run()

        self.assertEqual(3, len(results.methods))
        self.assertTrue('br.ufal.ic.easy.operations.Sum.impacted(int, int)' in
                        results.methods)
        self.assertTrue('br.ufal.ic.easy.operations.Sum.execute(int, int)' in
                        results.methods)
        self.assertTrue(
            'br.ufal.ic.easy.Calculator.sum(int, int)' in results.methods)
        self.assertEqual(2, len(results.constructors))
        self.assertTrue('br.ufal.ic.easy.Calculator()' in results.constructors)
        self.assertTrue(
            'br.ufal.ic.easy.operations.Sum()' in results.constructors)
Exemplo n.º 4
0
    def generate_test_suite(self, scenario, project_dep):
        evosuite = Evosuite(java=project_dep.java,
                            classpath=project_dep.parentReg,
                            tests_src=project_dep.tests_dst + '/' +
                            project_dep.project.get_project_name() + '/' +
                            scenario.merge_scenario.get_merge_hash(),
                            sut_class=project_dep.sut_class,
                            sut_classes=project_dep.sut_classes,
                            sut_method=project_dep.sut_method,
                            params=self.tool_parameters)
        safira = Safira(java=project_dep.java,
                        classes_dir=project_dep.parentReg,
                        mutant_dir=project_dep.baseDir)
        self.test_suite = evosuite.generate_with_impact_analysis(safira, False)

        return self.test_suite
Exemplo n.º 5
0
 def generate_test_suite(self, scenario, project_dep):
     randoop = Randoop_Modified(
         java=project_dep.java,
         classpath=project_dep.parentReg,
         tests_src=project_dep.tests_dst + '/' + project_dep.project.get_project_name() + '/' + scenario.merge_scenario.get_merge_hash(),
         sut_class=project_dep.sut_class,
         sut_classes=project_dep.sut_classes,
         sut_method=project_dep.sut_method,
         params=self.tool_parameters
     )
     safira = Safira(java=project_dep.java, classes_dir=project_dep.parentReg, mutant_dir=project_dep.baseDir)
     try:
         self.test_suite = randoop.generate_with_impact_analysis(safira, True)
     except Exception as e:
         print(e)
         self.test_suite = randoop.generate_with_impact_analysis(safira, False)
     return self.test_suite
Exemplo n.º 6
0
    def gen_evosuite_diff(self, scenario, project_dep):

        evosuite = Evosuite(
            java=project_dep.java,
            classpath=project_dep.classes_dir,
            sut_class=project_dep.sut_class,
            sut_method=project_dep.sut_method,
            params=self.evosuite_diff_params,
            tests_src=project_dep.tests_dst + '/' + project_dep.project.get_project_name() + '/' + scenario.merge_scenario.get_merge_hash()
        )
        safira = Safira(java=project_dep.java, classes_dir=project_dep.classes_dir,
                        mutant_dir=project_dep.dRegCp)
        try:
            self.suite_evosuite = evosuite.generate_with_impact_analysis(safira, True)
        except Exception as e:
            print(e)
        self.suite_evosuite_diff = evosuite.generate_differential(project_dep.dRegCp)
        return self.suite_evosuite_diff
Exemplo n.º 7
0
    def gen_evosuite(self, classes_dir, evosuite_params, mutant, sut_class,
                     tests_src):
        evosuite = Evosuite(java=self.java,
                            classpath=classes_dir,
                            tests_src=tests_src,
                            sut_class=sut_class,
                            params=evosuite_params)
        # suite = evosuite.generate()
        safira = Safira(java=self.java,
                        classes_dir=classes_dir,
                        mutant_dir=mutant.dir)
        self.suite_evosuite = evosuite.generate_with_impact_analysis(safira)
        if "Simulator" in sut_class:
            import distutils.dir_util
            distutils.dir_util.copy_tree("./config/",
                                         evosuite.suite_dir + "/config/")

        return self.suite_evosuite
Exemplo n.º 8
0
 def gen_randoop(self, classes_dir, mutant, randoop_params, sut_class,
                 tests_src):
     randoop = Randoop(java=self.java,
                       classpath=classes_dir,
                       tests_src=tests_src,
                       sut_class=sut_class,
                       params=randoop_params)
     safira = Safira(java=self.java,
                     classes_dir=classes_dir,
                     mutant_dir=mutant.dir)
     if "Bisect" in sut_class:
         self.suite_randoop = randoop.generate()
     else:
         self.suite_randoop = randoop.generate_with_impact_analysis(safira)
         if "Simulator" in sut_class:
             import distutils.dir_util
             distutils.dir_util.copy_tree("./config/",
                                          randoop.suite_dir + "/config/")
     return self.suite_randoop
Exemplo n.º 9
0
    def test_run_safira_timeout(self):
        safira = Safira(self.java, calculator_target_dir(),
                        calculator_src_aor_1())

        with self.assertRaises(subprocess.TimeoutExpired):
            safira.run(timeout=0)