Esempio n. 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')
Esempio n. 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")
Esempio n. 3
0
  def test_importDirs(self):
    cwd = os.getcwd()
    
    dirs = utils.getImportantDirs(self.project)
    
    # src_dir
    self.assertEquals(dirs[0], cwd + "/" + self.project.get_property('dir_source_main_python'))

    # test_dir
    self.assertEquals(dirs[1], cwd + "/" + self.project.get_property('dir_source_unittest_python'))

    # html_dir
    self.assertEquals(dirs[2], cwd + "/target/reports/coverage_html")

    # xml_file
    self.assertEquals(dirs[3], cwd + "/target/reports/coverage.xml")

    # xunit_file
    self.assertEquals(dirs[4], cwd + "/target/reports/coverage.xunit.xml")
Esempio n. 4
0
    def test_importDirs(self):
        cwd = os.getcwd()

        dirs = utils.getImportantDirs(self.project)

        # src_dir
        self.assertEquals(
            dirs[0],
            cwd + "/" + self.project.get_property('dir_source_main_python'))

        # test_dir
        self.assertEquals(
            dirs[1], cwd + "/" +
            self.project.get_property('dir_source_unittest_python'))

        # html_dir
        self.assertEquals(dirs[2], cwd + "/target/reports/coverage_html")

        # xml_file
        self.assertEquals(dirs[3], cwd + "/target/reports/coverage.xml")

        # xunit_file
        self.assertEquals(dirs[4], cwd + "/target/reports/coverage.xunit.xml")