tools/android/find_annotated_tests.py
def _GetTests(test_apks, apk_output_dir):
  """Return a list of all annotated tests and total test count"""
  result = []
  total_test_count = 0
  for test_apk in test_apks:
    logging.info('Current test apk: %s', test_apk)
    test_jar = os.path.join(
        apk_output_dir, constants.SDK_BUILD_TEST_JAVALIB_DIR,
        '%s.jar' % test_apk)
    all_tests = instrumentation_test_instance.GetAllTests(test_jar=test_jar)
    for test_class in all_tests:
      class_path = test_class['class']
      class_name = test_class['class'].split('.')[-1]

      class_annotations = test_class['annotations']
      class_bug_id = _GetBugId(class_annotations)
      for test_method in test_class['methods']:
        total_test_count += 1
        # getting annotation of each test case
        test_annotations = test_method['annotations']
        test_bug_id = _GetBugId(test_annotations)
        test_bug_id = test_bug_id if test_bug_id else class_bug_id
        test_annotations.update(class_annotations)
        # getting test method name of each test
        test_name = test_method['method']
        test_dict = {
            'bug_id': test_bug_id,
            'annotations': test_annotations,
            'test_name': test_name,
            'test_apk_name': test_apk,
            'class_name': class_name,
            'class_path': class_path
        }
        result.append(test_dict)

  logging.info('Total count of tests in all test apks: %d', total_test_count)
  return result, total_test_count
Return a list of all annotated tests and total test count
Return a list of all annotated tests and total test count
Return a list of all annotated tests and total test count
def _GetTests(test_apks, apk_output_dir):
  result = []
  total_test_count = 0
  for test_apk in test_apks:
    logging.info('Current test apk: %s', test_apk)
    test_jar = os.path.join(
        apk_output_dir, constants.SDK_BUILD_TEST_JAVALIB_DIR,
        '%s.jar' % test_apk)
    all_tests = instrumentation_test_instance.GetAllTests(test_jar=test_jar)
    for test_class in all_tests:
      class_path = test_class['class']
      class_name = test_class['class'].split('.')[-1]
      class_annotations = test_class['annotations']
      class_bug_id = _GetBugId(class_annotations)
      for test_method in test_class['methods']:
        total_test_count += 1
        test_annotations = test_method['annotations']
        test_bug_id = _GetBugId(test_annotations)
        test_bug_id = test_bug_id if test_bug_id else class_bug_id
        test_annotations.update(class_annotations)
        test_name = test_method['method']
        test_dict = {
            'bug_id': test_bug_id,
            'annotations': test_annotations,
            'test_name': test_name,
            'test_apk_name': test_apk,
            'class_name': class_name,
            'class_path': class_path
        }
        result.append(test_dict)
  logging.info('Total count of tests in all test apks: %d', total_test_count)
  return result, total_test_count
def _GetTests ( test_apks , apk_output_dir ) : result = [ ] total_test_count = 0 for test_apk in test_apks : logging . info ( 'Current test apk: %s' , test_apk ) test_jar = os . path . join ( apk_output_dir , constants . SDK_BUILD_TEST_JAVALIB_DIR , '%s.jar' % test_apk ) all_tests = instrumentation_test_instance . GetAllTests ( test_jar = test_jar ) for test_class in all_tests : class_path = test_class [ 'class' ] class_name = test_class [ 'class' ] . split ( '.' ) [ - 1 ] class_annotations = test_class [ 'annotations' ] class_bug_id = _GetBugId ( class_annotations ) for test_method in test_class [ 'methods' ] : total_test_count += 1 test_annotations = test_method [ 'annotations' ] test_bug_id = _GetBugId ( test_annotations ) test_bug_id = test_bug_id if test_bug_id else class_bug_id test_annotations . update ( class_annotations ) test_name = test_method [ 'method' ] test_dict = { 'bug_id' : test_bug_id , 'annotations' : test_annotations , 'test_name' : test_name , 'test_apk_name' : test_apk , 'class_name' : class_name , 'class_path' : class_path } result . append ( test_dict ) logging . info ( 'Total count of tests in all test apks: %d' , total_test_count ) return result , total_test_count
Return a list of all annotated tests and total test count
Return a list of all annotated tests and total test count
"""Return a list of all annotated tests and total test count""" # getting annotation of each test case # getting test method name of each test
test_apks
apk_output_dir