Bug 1899415 - Update Android smoke test generator for experiments. r=aaronmt DONTBUILD

Differential Revision: https://phabricator.services.mozilla.com/D211936
This commit is contained in:
Benjamin Forehand Jr 2024-05-29 22:53:17 +00:00
Родитель 3bc09d64cf
Коммит 3f6e4aaf9d
4 изменённых файлов: 57 добавлений и 14 удалений

Просмотреть файл

@ -92,7 +92,5 @@ class SurveyExperimentIntegrationTest {
}.clickNoThanksSurveyButton { }.clickNoThanksSurveyButton {
verifyTabCounter("0") verifyTabCounter("0")
} }
checkExperimentExists()
} }
} }

Просмотреть файл

@ -1,8 +1,20 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import argparse
import subprocess import subprocess
from pathlib import Path from pathlib import Path
import yaml import yaml
parser = argparse.ArgumentParser("Options for android apk downloader")
parser.add_argument(
"--test-files", nargs="+", help="List of test files to generate tests from"
)
args = parser.parse_args()
def search_for_smoke_tests(tests_name): def search_for_smoke_tests(tests_name):
"""Searches for smoke tests within the requested test module.""" """Searches for smoke tests within the requested test module."""
@ -21,16 +33,16 @@ def search_for_smoke_tests(tests_name):
code = file.read().split(" ") code = file.read().split(" ")
code = [item for item in code if item != ""] code = [item for item in code if item != ""]
# Gets the class name from the path e.g.: .ui/HomescreenTest.kt
class_name = f"{file_name.name.strip('kt').strip('.').split('/')[-1]}"
# This is a custom annotation found in fenix/customannotations/SmokeTest.kt
for count, item in enumerate(code): for count, item in enumerate(code):
if "class" in item or "@SmokeTest" in item: if "@SmokeTest" in item:
locations.append(count) locations.append(count)
for location in locations: for location in locations:
if len(test_names) == 0: test_names.append(f"{class_name}#{code[location+3].strip('()')}")
class_name = code[location + 1]
test_names.append(class_name)
else:
test_names.append(f"{class_name}#{code[location+3].strip('()')}")
return test_names return test_names
@ -72,10 +84,16 @@ def test_smoke_{test_name}(setup_experiment, gradlewbuild):
if __name__ == "__main__": if __name__ == "__main__":
test_modules = None test_modules = []
args = parser.parse_args()
if args.test_files:
test_modules = args.test_files
else:
with open("variables.yaml", "r") as file:
tests = yaml.safe_load(file)
test_modules = [test for test in tests.get("smoke_tests")]
create_test_file() create_test_file()
with open("variables.yaml", "r") as file: print(f"Created tests for modules: {test_modules}")
test_modules = yaml.safe_load(file) for item in test_modules:
for item in test_modules.get("smoke_tests"):
tests = search_for_smoke_tests(item) tests = search_for_smoke_tests(item)
generate_smoke_tests(tests) generate_smoke_tests(tests)

Просмотреть файл

@ -3,6 +3,6 @@ addopts = --verbose --html=results/index.html --self-contained-html --variables=
log_cli = true log_cli = true
log_cli_level = info log_cli_level = info
markers = markers =
smoke: Smoke tests smoke_test: Smoke tests
messaging_survey: Survey message experiments messaging_survey: Survey message experiments
messaging_homescreen: homescreen message experiments messaging_homescreen: homescreen message experiments

Просмотреть файл

@ -7,4 +7,31 @@ urls:
prod_server: "https://experimenter.services.mozilla.com" prod_server: "https://experimenter.services.mozilla.com"
telemetry_server: "http://172.25.58.187:5000" telemetry_server: "http://172.25.58.187:5000"
smoke_tests: smoke_tests:
- "AddressAutofillTest" - AddressAutofillTest
- BookmarksTest
- CookieBannerBlockerTest
- CrashReportingTest
- CreditCardAutofillTest
- CustomTabsTest
- DownloadTest
- EnhancedTrackingProtectionTest
- FirefoxSuggestTest
- HistoryTest
- HomeScreenTest
- LoginsTest
- MainMenuTest
- MediaNotificationTest
- OnboardingTest
- PDFViewerTest
- RecentlyClosedTabsTest
- SearchTest
- SettingsDeleteBrowsingDataTest
- SettingsAddonsTest
- SettingsGeneralTest
- SettingsHomepageTest
- SettingsSearchTest
- SitePermissionsTest
- SponsoredShortcutsTest
- TabbedBrowsingTest
- TextSelectionTest
- TopSitesTest