Minor changes to system example test to match docs

Signed-off-by: evanchia <evanchia@amazon.com>
This commit is contained in:
evanchia
2021-06-30 15:29:06 -07:00
parent 0730960a4f
commit 6308d01456
@@ -3,7 +3,7 @@ Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright
SPDX-License-Identifier: Apache-2.0 OR MIT
Example test using LyTestTools to test Lumberyard.
Example test using LyTestTools to test Open 3D Engine.
"""
# Python built-in dependencies.
import logging
@@ -11,7 +11,7 @@ import logging
# Third party dependencies.
import pytest
# ly_test_tools dependencies.
# Optional ly_test_tools dependencies.
import ly_test_tools.log.log_monitor
import ly_remote_console.remote_console_commands as remote_console_commands
@@ -22,28 +22,6 @@ import ly_remote_console.remote_console_commands as remote_console_commands
logger = logging.getLogger(__name__)
@pytest.fixture
def remote_console(request):
"""
Creates a RemoteConsole() class instance to send console commands to the
Lumberyard client console.
:param request: _pytest.fixtures.SubRequest class that handles getting
a pytest fixture from a pytest function/fixture.
:return: ly_remote_console.remote_console_commands.RemoteConsole class instance
representing the Lumberyard remote console executable.
"""
# Initialize the RemoteConsole object to send commands to the Lumberyard client console.
console = remote_console_commands.RemoteConsole()
# Custom teardown method for this remote_console fixture.
def teardown():
console.stop()
# Utilize request.addfinalizer() to add custom teardown() methods.
request.addfinalizer(teardown) # This pattern must be used in pytest version
return console
# Shared parameters & fixtures for all test methods inside the TestSystemExample class.
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.parametrize('project', ['AutomatedTesting'])
@@ -55,6 +33,41 @@ class TestSystemExample(object):
For this test, we placed unique test values in test methods and shared test values in the test class.
We also assume building has already been done, but the test should error if the build is mis-configured.
"""
# This test method only needs pytest.mark report values and shared test class parameters.
@pytest.mark.parametrize('processes_to_kill', ['Editor.exe'])
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
def test_SystemTestExample_WindowsPlatform_LaunchEditor(self, editor, processes_to_kill, launcher_platform):
"""
Tests launching the O3DE Editor is successful with the current build.
"""
# Launch the O3DE Editor & verify load is successful:
with editor.start():
assert editor.is_alive(), (
'Editor failed to launch for the current O3DE build.')
@pytest.fixture
def remote_console(request):
"""
Creates a RemoteConsole() class instance to send console commands to the
O3DE client console.
:param request: _pytest.fixtures.SubRequest class that handles getting
a pytest fixture from a pytest function/fixture.
:return: ly_remote_console.remote_console_commands.RemoteConsole class instance
representing the O3DE Remote Console executable.
"""
# Initialize the RemoteConsole object to send commands to the O3DE client console.
console = remote_console_commands.RemoteConsole()
# Custom teardown method for this remote_console fixture.
def teardown():
console.stop()
# Utilize request.addfinalizer() to add custom teardown() methods.
request.addfinalizer(teardown) # This pattern must be used in pytest version
return console
# This test method needs specific parameters not shared by all other tests in the class.
# For targeting specific launchers, use the 'launcher_platform' pytest param like below:
# @pytest.mark.parametrize("launcher_platform", ['android'])
@@ -62,39 +75,24 @@ class TestSystemExample(object):
# @pytest.mark.parametrize("asset_processor_platform", ['android'])
@pytest.mark.parametrize('level', ['simple_jacklocomotion'])
@pytest.mark.parametrize('load_wait', [120])
@pytest.mark.test_case_id('C16806863')
def test_SystemTestExample_AllSupportedPlatforms_LaunchAutomatedTesting(
# launcher_platform, asset_processor_platform, # Re-add these here if you plan to use them.
self, launcher, remote_console, level, load_wait):
def test_SystemTestExample_AllSupportedPlatforms_LaunchAutomatedTesting(self, launcher, remote_console, level,
load_wait):
"""
Tests launching the AutomatedTesting then launches the Lumberyard client &
Tests launching the AutomatedTesting then launches the O3DE client &
loads the "simple_jacklocomotion" level using the remote console.
Assumes the user already setup & built their machine for the test.
"""
# Launch the Lumberyard client & remote console test case:
# Launch the O3DE client & remote console test case:
with launcher.start():
remote_console.start()
# Wait for the expected log line to appear
launcher_load = remote_console.expect_log_line(
match_string='Level system is loading "simple_jacklocomotion"',
timeout=load_wait)
# Assert loading was successful using remote console logs:
assert launcher_load, (
'Launcher failed to load Lumberyard client with the '
f'"{level}" level - waited "{load_wait}" seconds.')
# This test method only needs pytest.mark report values and shared test class parameters.
@pytest.mark.parametrize('processes_to_kill', ['Editor.exe'])
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
@pytest.mark.test_case_id('C16806864')
def test_SystemTestExample_AllSupportedPlatforms_LaunchEditor(self, editor, processes_to_kill, launcher_platform):
"""
Tests launching the Lumberyard Editor is successful with the current build.
"""
# Launch the Lumberyard editor & verify load is successful:
with editor.start():
assert editor.is_alive(), (
'Editor failed to launch for the current Lumberyard build.')
assert launcher_load, ('Launcher failed to load O3DE client with the "{level}" level - waited "{load_wait}" '
'seconds.')
# Log monitoring example test.
@pytest.mark.parametrize('level', ['simple_jacklocomotion'])
@@ -106,7 +104,7 @@ class TestSystemExample(object):
"""
Tests that the logging paths created by LyTestTools can be monitored for results using the log monitor.
"""
# Launch the Lumberyard client & initialize the log monitor.
# Launch the O3DE client & initialize the log monitor.
file_to_monitor = launcher.workspace.info_log_path
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher,
log_file_path=file_to_monitor)
@@ -115,7 +113,7 @@ class TestSystemExample(object):
for expected_line in expected_lines:
logger.info(expected_line)
# Start the Lumberyard client & test that the lines we logged can be viewed by the log monitor.
# Start the O3DE client & test that the lines we logged can be viewed by the log monitor.
with launcher.start():
log_test = log_monitor.monitor_log_for_lines(
expected_lines=expected_lines, # Defaults to None.