示例#1
0
    def on_exec_testcase_button_click(self, event):
        """ Action performed when user clicks the run testcase button.
        """

        self.log.trace("Handle run testcase button click by user.")
        result = {'successful': False}

        try:
            self.log.debug("Building test run ...")
            # determine test path from input fields
            data = self.determine_test_path_from_input_fields()
            module_name = data['module']
            feature_name = data['feature']
            story_name = data['user story']
            test_name = data['test']
            case_name = data['testcase']

            # determine publish plan id
            publish_id = self.input_publish_id.GetString(0, -1)

            # build test run
            testrun = TestRun(self.log, self.database, name='Debug Test Run', submodule_id=3,
                testcases=[], results_plan_id=publish_id)
            testcases_to_run = testrun.build_testcase_list_for_run(module_id=module_name,
                feature_id=feature_name, story_id=story_name, test_id=test_name,
                case_id=case_name)['testcases']

            # determine class
            self.log.trace("Getting string from testcase class input field ...")
            testcase_class = self.input_testcase_class.GetString(
                self.input_testcase_class.GetSelection())
            testrun.filter_testcases_by_class(testcases_to_run, testcase_class)

            # execute test case
            testrun.testcases = testcases_to_run
            testrun.run()

            self.log.trace("Handled run testcase button click by user.")
            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, "handle run testcase button click by user")
示例#2
0
   def runAndObserve(self, specName, observers_ = [], saveResults = True):

      specId, spec = yield self._testDb.getSpecByName(specName)
      casesByTestee = yield self._testDb.generateCasesByTestee(specId)
      _observers = observers_[:]
      #_observers = observers_

      ## publish WAMP event on test case finished
      ##
      def notify(runId, testRun, testCase, result, remaining):
         if testCase:
            evt = {
               'testee': testRun.testee.name,
               'runId': runId,
               'index': testCase.index,
               'passed': result.passed,
               'remaining': remaining
            }
            topic = "http://api.testsuite.wamp.ws/testrun#onResult"
         else:
            evt = {
               'testee': testRun.testee.name,
               'runId': runId
            }
            topic = "http://api.testsuite.wamp.ws/testrun#onComplete"

         self.dispatch(topic, evt)
         #if result and not result.passed:
         #   print topic, evt

      if self.dispatch:
         _observers.append(notify)

      ## save test results to test database
      ##
      def save(runId, testRun, testCase, result, remaining):
         if testCase:
            self._testDb.saveResult(runId, testRun, testCase, result, saveResults)

      if saveResults:
         _observers.append(save)

      testRuns = []
      for obj in spec['testees']:
         testee = Testee(**obj)
         cases = casesByTestee.get(testee.name, [])
         if testee.options.has_key('randomize') and testee.options['randomize'] is not None:
            randomize = testee.options['randomize']
         elif spec.has_key('options') and spec['options'].has_key('randomize') and spec['options']['randomize'] is not None:
            randomize = spec['options']['randomize']
         else:
            randomize = False
         testRun = TestRun(testee, cases, randomize = randomize)
         testRuns.append(testRun)

      runId = yield self._testDb.newRun(specId)

      print
      print "Autobahn Fuzzing WAMP Client"
      print
      print "Autobahn Version          : %s" % autobahn.version
      print "AutobahnTestsuite Version : %s" % autobahntestsuite.version
      #print "WAMP Test Cases           : %d" % len(self._caseSet.Cases)
      print "WAMP Testees              : %d" % len(spec["testees"])
      print
      for testRun in testRuns:
         print "%s @ %s : %d test cases prepared" % (testRun.testee.name, testRun.testee.url, testRun.remaining())
      print
      print

      def progress(runId, testRun, testCase, result, remaining):
         for obsv in _observers:
            try:
               obsv(runId, testRun, testCase, result, remaining)
            except Exception, e:
               print e
示例#3
0
                # trigger test
                builds_triggered += 1
                minos.trigger_build('tartaros', params)

            log.info("Triggered %s test runs." % builds_triggered)

        except KeyError, e:
            log.error(e)
            log.error("Invalid test %s specified." % test)

elif mode == 'testing':
    # instance database for TeamCity testing
    database = Database(Logger(logging_level='info'))

    # initialize test run object
    testrun = TestRun(log, database, name=test_name, submodule_id=2,
                      results_plan_id=results_plan_id, int_dvr_ip=int_dvr_ip)

    # build testcase list for test run
    testcases = testrun.build_testcase_list_for_run(module_id=module,
        feature_id=feature, story_id=story, test_id=test,
        case_id=testcase, case_class=testcase_class)['testcases']

    # filter by class
    if testcase_class is not None:
        testrun.filter_testcases_by_class(testcases, testcase_class)

    # filter by type
    if testcase_type is not None:
        testrun.filter_testcases_by_type(testcases, testcase_type)
    if testcase_type.lower() != 'dvr integration' and module.lower() != 'dvr integration':
        testrun.filter_testcases_by_type(testcases, 'dvr integration', inclusive=False)
示例#4
0
    def run_test(self, build, test_name, results_plan_id, module=None, feature=None, story=None,
                 test=None, case=None, case_class=None, case_type=None, int_dvr_ip=None,
                 mode=None):
        """ Run test with given parameters.
        """

        operation = inspect.stack()[0][3]
        result = None

        try:
            self.log.trace("%s ..." % operation.replace('_', ' '))

            # instance database for TeamCity testing
            if str(mode).lower() == 'thanatos':
                database = Database(Logger(logging_level='info'), path=getcwdu()+"\\tartaros.sqlite")
                testcase = ThanatosTestCase(self.log, database, case)
                testcase.run()

            else:
                database = Database(Logger(logging_level='info'))

                # initialize test run object
                testrun = TestRun(self.log, database, name=test_name, submodule_id=2,
                                  results_plan_id=results_plan_id, int_dvr_ip=int_dvr_ip)

                # build testcase list for test run
                testcases = testrun.build_testcase_list_for_run(module_id=module,
                    feature_id=feature, story_id=story, test_id=test,
                    case_id=case, case_class=case_class)['testcases']

                # filter by class
                if case_class is not None:
                    testrun.filter_testcases_by_class(testcases, case_class)

                # filter by type
                if case_type is not None:
                    testrun.filter_testcases_by_type(testcases, case_type)

                    if case_type.lower() != 'dvr integration' and str(module) != '9'\
                            and str(module).lower() != 'dvr integration':
                        testrun.filter_testcases_by_type(testcases, 'dvr integration', inclusive=False)

                # set testcase list for test run
                testrun.testcases = testcases

                if str(build).lower() != 'none':
                    # setup test environment
                    testrun.setup_test_environment(build, test_name)
                else:
                    testrun.setup_test_environment(build, test_name, installing=False)

                # execute test run
                testrun.run()

                # teardown test environment
                testrun.teardown_test_environment()

                #else:
                #    self.log.error("Failed to setup test environment. %s is not a valid build." % build)

                # compile results
                result = None

        except BaseException, e:
            self.handle_exception(self.log, e, operation)