Exemple #1
0
def run_unit_tests(project, logger):

  # set cwd to project root
  src_dir, test_dir, html_dir, xml_file, xunit_file = getImportantDirs(project)

  logger.debug("SRC dir: %s" % src_dir)
  logger.debug("Test dir: %s" % test_dir)
  logger.debug("HTML Reports dir: %s" % html_dir)
  logger.debug("XML Report: %s" % xml_file)
  logger.debug("Xunit Report: %s" % xunit_file) 

  if os.path.exists(html_dir) == False:
    os.makedirs(html_dir)

  logger.debug("Setting initial nose properties")

  project.set_property('nose_where', test_dir)
  project.set_property('nose_cover-package', src_dir)
  project.set_property('nose_with-coverage', True)
  project.set_property('nose_cover-xml', True)
  project.set_property('nose_cover-xml-file', xml_file)
  project.set_property('nose_cover-html', True)
  project.set_property('nose_cover-html-dir', html_dir)
  project.set_property('nose_with-xunit', True)
  project.set_property('nose_xunit-file', xunit_file)

  if project.get_property('verbose'):
    project.set_property('nose_nocapture', True)
    project.set_property('verbose', True)

  logger.debug("Collecting nose properties")

  args = ['nosetest']

  args = prepareArgs(project)
  args.insert(0, 'nosetests')

  for arg in args:
    logger.debug('Nose arg: %s' % arg)

  noseEnv = os.environ.copy()
  #noseEnv["PYTHONPATH"] = "src/main/python"

  logger.info("Launching nosetests")
  noseProc = subprocess.Popen(args, stdout=subprocess.PIPE, env=noseEnv, shell=True)

  while noseProc.poll() is None:
    l = noseProc.stdout.readline()
    logger.debug(l)

  if noseProc.returncode != 0:
    logger.error('Unit tests failed with exit code %s' % noseProc.returncode)
    raise BuildFailedException('Unit tests did not pass')
Exemple #2
0
def run_unit_tests(project, logger):

    # set cwd to project root
    src_dir, test_dir, html_dir, xml_file, xunit_file = getImportantDirs(project)

    logger.debug("SRC dir: %s" % src_dir)
    logger.debug("Test dir: %s" % test_dir)
    logger.debug("HTML Reports dir: %s" % html_dir)
    logger.debug("XML Report: %s" % xml_file)
    logger.debug("Xunit Report: %s" % xunit_file)

    if os.path.exists(html_dir) == False:
        os.makedirs(html_dir)

    logger.debug("Setting initial nose properties")

    project.set_property("nose_where", test_dir)
    project.set_property("nose_cover-package", src_dir)
    project.set_property("nose_with-coverage", True)
    project.set_property("nose_cover-xml", True)
    project.set_property("nose_cover-xml-file", xml_file)
    project.set_property("nose_cover-html", True)
    project.set_property("nose_cover-html-dir", html_dir)
    project.set_property("nose_with-xunit", True)
    project.set_property("nose_xunit-file", xunit_file)

    if project.get_property("verbose"):
        project.set_property("nose_nocapture", True)
        project.set_property("verbose", True)

    logger.debug("Collecting nose properties")

    args = ["nosetest"]

    args = prepareArgs(project)
    args.insert(0, "nosetests")

    for arg in args:
        logger.debug("Nose arg: %s" % arg)

    noseEnv = os.environ.copy()
    noseEnv["PYTHONPATH"] = "src/main/python"

    logger.info("Launching nosetests")
    noseProc = subprocess.Popen(args, stdout=subprocess.PIPE, env=noseEnv)

    while noseProc.poll() is None:
        l = noseProc.stdout.readline()
        logger.debug(l)

    if noseProc.returncode != 0:
        logger.error("Unit tests failed with exit code %s" % noseProc.returncode)
        raise BuildFailedException("Unit tests did not pass")
  def test_prepareArgs(self):
    self.project.set_property('nose_numeric', 1)
    self.project.set_property('nose_string', 'foobar')
    self.project.set_property('nose_array', ['one','two','three'])
    self.project.set_property('nose_true', True)
    self.project.set_property('nose_true-array', [True, True])
    
    self.project.set_property('nose_unused1', False)
    self.project.set_property('nose_unused2', None)

    args = utils.prepareArgs(self.project)

    self.assertEquals(len(args), 8)

    self.assertEquals('--numeric' in args, True)
    self.assertEquals('--string=foobar' in args, True)
    self.assertEquals('--array=one' in args, True)
    self.assertEquals('--array=two' in args, True)
    self.assertEquals('--array=three' in args, True)
    self.assertEquals('--true' in args, True)
    self.assertEquals('--true-array' in args, True)
    self.assertEquals('--true-array' in args, True)
Exemple #4
0
    def test_prepareArgs(self):
        self.project.set_property('nose_numeric', 1)
        self.project.set_property('nose_string', 'foobar')
        self.project.set_property('nose_array', ['one', 'two', 'three'])
        self.project.set_property('nose_true', True)
        self.project.set_property('nose_true-array', [True, True])

        self.project.set_property('nose_unused1', False)
        self.project.set_property('nose_unused2', None)

        args = utils.prepareArgs(self.project)

        self.assertEquals(len(args), 8)

        self.assertEquals('--numeric' in args, True)
        self.assertEquals('--string=foobar' in args, True)
        self.assertEquals('--array=one' in args, True)
        self.assertEquals('--array=two' in args, True)
        self.assertEquals('--array=three' in args, True)
        self.assertEquals('--true' in args, True)
        self.assertEquals('--true-array' in args, True)
        self.assertEquals('--true-array' in args, True)