def test_fetch_test_error_release(self): """Ensures that unexpected release output raises error.""" with self.assertRaises(shard_util.ShardingError) as context: shard_util.fetch_test_names_for_release( RELEASE_APP_OTOOL_OUTPUT_CLASS_NOT_IN_PAIRS) expected_message = ( 'Incorrect otool output in which a test class name doesn\'t appear in ' 'group of 2. Test class: KeyboardTest') self.assertTrue(expected_message in str(context.exception))
def test_fetch_test_counts_release_114(self): """Test the release output from otool in Xcode 11.4""" resp = shard_util.fetch_test_names_for_release( RELEASE_APP_OTOOL_OUTPUT_114) self.assertEqual(len(resp), 10) expected_test_names = [ ('CacheTestCase', 'testA'), ('CacheTestCase', 'testB'), ('CacheTestCase', 'testc'), ('KeyboardTest', 'testD'), ('KeyboardTest', 'testE'), ('KeyboardTest', 'testF'), ('ToolBarTestCase', 'testG'), ('ToolBarTestCase', 'testH'), ('ToolBarTestCase', 'DISABLED_testI'), ('ToolBarTestCase', 'FLAKY_testJ'), ] for test_name in expected_test_names: self.assertTrue(test_name in resp) test_cases = map(lambda (test_case, test_method): test_case, resp) # ({'KeyboardTest': 3, 'CacheTestCase': 3, # 'ToolBarTestCase': 4}) counts = collections.Counter(test_cases).most_common() name, _ = counts[0] self.assertEqual(name, 'ToolBarTestCase')
def test_balance_into_sublists_release(self): """Ensure the balancing algorithm works""" resp = shard_util.fetch_test_names_for_release( RELEASE_APP_OTOOL_OUTPUT) test_cases = map(lambda (test_case, test_method): test_case, resp) test_counts = collections.Counter(test_cases) sublists_3 = shard_util.balance_into_sublists(test_counts, 3) self.assertEqual(len(sublists_3), 3) # KeyboardTest has 3 # CacheTestCase has 3 # ToolbarTest Case has 2 self.assertEqual(len(sublists_3[0]), 1) self.assertEqual(len(sublists_3[1]), 1) self.assertEqual(len(sublists_3[2]), 1)
def test_fetch_test_counts_release(self): """Ensures that the release output is formatted correctly""" resp = shard_util.fetch_test_names_for_release( RELEASE_APP_OTOOL_OUTPUT) self.assertEqual(len(resp), 8) expected_test_names = [('CacheTestCase', 'testA'), ('CacheTestCase', 'testB'), ('CacheTestCase', 'testc'), ('KeyboardTest', 'testD'), ('KeyboardTest', 'testE'), ('KeyboardTest', 'testF'), ('ToolBarTestCase', 'testG'), ('ToolBarTestCase', 'testH')] for test_name in expected_test_names: self.assertTrue(test_name in resp) test_cases = map(lambda (test_case, test_method): test_case, resp) # ({'KeyboardTest': 3, 'CacheTestCase': 3, # 'ToolBarTestCase': 2}) counts = collections.Counter(test_cases).most_common() name, _ = counts[0] self.assertEqual(name, 'KeyboardTest')